public override int GetHashCode() { return (Hash.Combine(StringComparer.OrdinalIgnoreCase.GetHashCode(_filePath ?? string.Empty), Hash.Combine(_assemblyIdentity != null ? _assemblyIdentity.GetHashCode() : 0, Hash.Combine(_language.GetHashCode(), s_symbolIdComparer.GetHashCode(_symbolId))))); }
public override int GetHashCode() { return (Hash.Combine(StringComparer.OrdinalIgnoreCase.GetHashCode(_filePath ?? string.Empty), Hash.Combine(_assemblyIdentity?.GetHashCode() ?? 0, Hash.Combine(_metadataId?.GetHashCode() ?? 0, Hash.Combine(_language.GetHashCode(), Hash.Combine(s_symbolIdComparer.GetHashCode(_symbolId), _allowDecompilation.GetHashCode())))))); }
public void Equality() { // Generate identical assembly identities. Check that they are // indeed the same. for (int i = 0; i < 1000; i++) { var name = rng.NextAsciiString(rng.Next(0, 100)); var first = new AssemblyIdentity(name); var second = new AssemblyIdentity(name); Assert.AreEqual(first, second); Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); int annotationCount = rng.Next(0, 20); for (int j = 0; j < annotationCount; j++) { var key = rng.NextAsciiString(rng.Next(0, 20)); var value = rng.NextAsciiString(rng.Next(0, 100)); string oldValue; if (!first.TryGetAnnotation(key, out oldValue)) { oldValue = null; } first = first.WithAnnotation(key, value); if (oldValue != value) { Assert.AreNotEqual(first, second); } second = second.WithAnnotation(key, value); Assert.AreEqual(first, second); Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); } } }
public void Equality() { var id1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false); var id11 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false); var id2 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false); var id22 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false); var id3 = new AssemblyIdentity("Foo!", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false); var id4 = new AssemblyIdentity("Foo", new Version(1, 0, 1, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false); var id5 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "en-US", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false); var id6 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", default(ImmutableArray<byte>), hasPublicKey: false, isRetargetable: false); var id7 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: true, isRetargetable: false); var id8 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: true); var win1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime); var win2 = new AssemblyIdentity("Bar", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime); var win3 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime); Assert.True(id1.Equals(id1)); Assert.True(id1.Equals(id2)); Assert.True(id2.Equals(id1)); Assert.True(id1.Equals(id11)); Assert.True(id11.Equals(id1)); Assert.True(id2.Equals(id22)); Assert.True(id22.Equals(id2)); Assert.False(id1.Equals(id3)); Assert.False(id1.Equals(id4)); Assert.False(id1.Equals(id5)); Assert.False(id1.Equals(id6)); Assert.False(id1.Equals(id7)); Assert.False(id1.Equals(id8)); Assert.Equal((object)id1, id1); Assert.NotNull(id1); Assert.False(id2.Equals((AssemblyIdentity)null)); Assert.Equal(id1.GetHashCode(), id2.GetHashCode()); Assert.False(win1.Equals(win2)); Assert.False(win1.Equals(id1)); Assert.True(win1.Equals(win3)); Assert.Equal(win1.GetHashCode(), win3.GetHashCode()); }
public void Equality() { var id1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false); var id11 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false); var id2 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false); var id22 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false); var id3 = new AssemblyIdentity("Foo!", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false); var id4 = new AssemblyIdentity("Foo", new Version(1, 0, 1, 0), "", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false); var id5 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "en-US", RoPublicKeyToken1, hasPublicKey: false, isRetargetable: false); var id6 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", default(ImmutableArray <byte>), hasPublicKey: false, isRetargetable: false); var id7 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKeyToken1, hasPublicKey: true, isRetargetable: false); var id8 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: true); var win1 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime); var win2 = new AssemblyIdentity("Bar", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime); var win3 = new AssemblyIdentity("Foo", new Version(1, 0, 0, 0), "", RoPublicKey1, hasPublicKey: true, isRetargetable: false, contentType: AssemblyContentType.WindowsRuntime); Assert.True(id1.Equals(id1)); Assert.True(id1.Equals(id2)); Assert.True(id2.Equals(id1)); Assert.True(id1.Equals(id11)); Assert.True(id11.Equals(id1)); Assert.True(id2.Equals(id22)); Assert.True(id22.Equals(id2)); Assert.False(id1.Equals(id3)); Assert.False(id1.Equals(id4)); Assert.False(id1.Equals(id5)); Assert.False(id1.Equals(id6)); Assert.False(id1.Equals(id7)); Assert.False(id1.Equals(id8)); Assert.Equal((object)id1, id1); Assert.NotNull(id1); Assert.False(id2.Equals((AssemblyIdentity)null)); Assert.Equal(id1.GetHashCode(), id2.GetHashCode()); Assert.False(win1.Equals(win2)); Assert.False(win1.Equals(id1)); Assert.True(win1.Equals(win3)); Assert.Equal(win1.GetHashCode(), win3.GetHashCode()); }
public void EmptyAnnotationEquality() { // Generate identical assembly identities. Check that they are // indeed the same. var first = new AssemblyIdentity("path/to/file") .WithAnnotation("", "") .WithAnnotation("a", "b") .WithAnnotation("a", "c"); var second = new AssemblyIdentity("path/to/file") .WithAnnotation("a", "b") .WithAnnotation("a", "c") .WithAnnotation( new string(new char[] { }), new string(new char[] { })); Assert.AreEqual(first, second); Assert.AreEqual(first.GetHashCode(), second.GetHashCode()); }
public override int GetHashCode() { return(identity.GetHashCode()); }