Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional exclusions for dependency collection #6282

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,19 @@ private static bool IsHexChar(char c)

private static bool IsZeroVersionAssemblyPattern(string assemblyName)
{
return assemblyName.Length == 8
&& IsBase32Char(assemblyName[0])
&& IsBase32Char(assemblyName[1])
&& IsBase32Char(assemblyName[2])
&& IsBase32Char(assemblyName[3])
&& IsBase32Char(assemblyName[4])
&& IsBase32Char(assemblyName[5])
&& IsBase32Char(assemblyName[6])
&& IsBase32Char(assemblyName[7]);
// e.g.
// 454845b558934321ad350977dd095960
// akkynf62
return (assemblyName.Length == 8
&& IsBase32Char(assemblyName[0])
&& IsBase32Char(assemblyName[1])
&& IsBase32Char(assemblyName[2])
&& IsBase32Char(assemblyName[3])
&& IsBase32Char(assemblyName[4])
&& IsBase32Char(assemblyName[5])
&& IsBase32Char(assemblyName[6])
&& IsBase32Char(assemblyName[7]))
|| (assemblyName.Length >= 32 && IsHexString(assemblyName, 0));
}

private static bool IsBase32Char(char c)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,24 @@ public void DoesNotHaveChangesWhenAssemblyVersionIsZeroAndHasRandom8CharName()
}
}

[Theory]
[InlineData("454845b558934321ad350977dd095960")]
[InlineData("41e68894e3e54239abe61eb16cb0e158")]
[InlineData("a1bc683e730d425c9de5fdf00dbdc003")]
public void DoesNotHaveChangesWhenAssemblyVersionIsZeroAndHas32CharName(string name)
{
var ignoredName = CreateAssemblyName(new Version(0, 0, 0, 0), name: name);

var collector = new DependencyTelemetryCollector();
collector.AssemblyLoaded(ignoredName, "some-guid");

collector.HasChanges().Should().BeFalse($"{name} has a zero version");

var nonIgnoredName = CreateAssemblyName(new Version(1, 0, 0, 0), name: name);
collector.AssemblyLoaded(nonIgnoredName, "some-guid");
collector.HasChanges().Should().BeTrue($"{nonIgnoredName} has a non-zero version");
}

[Fact]
public void HasChangesWhenAddingSameAssemblyWithDifferentVersion()
{
Expand Down
Loading