public void CompareTo() { // For each pair of assembly strings... foreach (string assemblyString1 in s_assemblyStrings) { AssemblyName baseName1 = new AssemblyName(assemblyString1); foreach (string assemblyString2 in s_assemblyStrings) { AssemblyName baseName2 = new AssemblyName(assemblyString2); // ...and for each pair of production methods... foreach (ProduceAssemblyNameEx produce1 in s_producers) { foreach (ProduceAssemblyNameEx produce2 in s_producers) { AssemblyNameExtension a1 = produce1(assemblyString1); AssemblyNameExtension a2 = produce2(assemblyString2); int result = a1.CompareTo(a2); if (a1.Equals(a2)) { Assert.Equal(0, result); } if (a1.CompareBaseNameTo(a2) != 0) { Assert.Equal(a1.CompareBaseNameTo(a2), result); } if ( a1.CompareBaseNameTo(a2) == 0 && // Only check version if basenames match a1.Version != a2.Version ) { if (a1.Version == null) { // Expect -1 if a1.Version is null and the baseNames match Assert.Equal(-1, result); } else { Assert.Equal(a1.Version.CompareTo(a2.Version), result); } } int resultBaseline = String.Compare(a1.FullName, a2.FullName, StringComparison.OrdinalIgnoreCase); // Only check to see if the result and the resultBaseline match when the result baseline is 0 and the result is not 0. if (resultBaseline != result && resultBaseline == 0) { Assert.Equal(resultBaseline, result); } } } } } }
internal Assembly ResolveAssembly(object sender, ResolveEventArgs args) { AssemblyNameExtension that = new AssemblyNameExtension(args.Name); if (this.assemblyFiles != null) { if (this.assemblyNames == null) { this.assemblyNames = new AssemblyNameExtension[this.assemblyFiles.Length]; for (int k = 0; k < this.assemblyFiles.Length; k++) { ITaskItem item = this.assemblyFiles[k]; this.assemblyNames[k] = null; if ((item.ItemSpec != null) && File.Exists(item.ItemSpec)) { string metadata = item.GetMetadata("FusionName"); if ((metadata != null) && (metadata.Length > 0)) { this.assemblyNames[k] = new AssemblyNameExtension(metadata); } } } } for (int i = 0; i < this.assemblyNames.Length; i++) { AssemblyNameExtension extension2 = this.assemblyNames[i]; if ((extension2 != null) && (extension2.CompareTo(that) == 0)) { return(Assembly.UnsafeLoadFrom(this.assemblyFiles[i].ItemSpec)); } } for (int j = 0; j < this.assemblyNames.Length; j++) { AssemblyNameExtension extension3 = this.assemblyNames[j]; if ((extension3 != null) && (string.Compare(that.Name, extension3.Name, StringComparison.CurrentCultureIgnoreCase) == 0)) { return(Assembly.UnsafeLoadFrom(this.assemblyFiles[j].ItemSpec)); } } } return(null); }
public int CompareTo(AssemblyNameReference other) { return(assemblyName.CompareTo(other.assemblyName)); }