Skip to content

Commit

Permalink
Add additional exclusions for dependency collection
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewlock committed Nov 14, 2024
1 parent 1faff1a commit 42843f5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
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

0 comments on commit 42843f5

Please sign in to comment.