Browse Source

Sort custom attributes - the C# compiler seems to add these in random order, so by sorting them we eliminate unnecessary differences when comparing multiple versions of an assembly.

pull/275/merge
Daniel Grunwald 14 years ago
parent
commit
6d22ff99ad
  1. 6
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. 1
      ILSpy/Languages/CSharpLanguage.cs
  3. 1
      ILSpy/VB/VBLanguage.cs

6
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -1317,7 +1317,7 @@ namespace ICSharpCode.Decompiler.Ast
{ {
if (customAttributeProvider.HasCustomAttributes) { if (customAttributeProvider.HasCustomAttributes) {
var attributes = new List<ICSharpCode.NRefactory.CSharp.Attribute>(); var attributes = new List<ICSharpCode.NRefactory.CSharp.Attribute>();
foreach (var customAttribute in customAttributeProvider.CustomAttributes) { foreach (var customAttribute in customAttributeProvider.CustomAttributes.OrderBy(a => a.AttributeType.FullName)) {
if (customAttribute.AttributeType.Name == "ExtensionAttribute" && customAttribute.AttributeType.Namespace == "System.Runtime.CompilerServices") { if (customAttribute.AttributeType.Name == "ExtensionAttribute" && customAttribute.AttributeType.Namespace == "System.Runtime.CompilerServices") {
// don't show the ExtensionAttribute (it's converted to the 'this' modifier) // don't show the ExtensionAttribute (it's converted to the 'this' modifier)
continue; continue;
@ -1387,8 +1387,8 @@ namespace ICSharpCode.Decompiler.Ast
if (!secDeclProvider.HasSecurityDeclarations) if (!secDeclProvider.HasSecurityDeclarations)
return; return;
var attributes = new List<ICSharpCode.NRefactory.CSharp.Attribute>(); var attributes = new List<ICSharpCode.NRefactory.CSharp.Attribute>();
foreach (var secDecl in secDeclProvider.SecurityDeclarations) { foreach (var secDecl in secDeclProvider.SecurityDeclarations.OrderBy(d => d.Action)) {
foreach (var secAttribute in secDecl.SecurityAttributes) { foreach (var secAttribute in secDecl.SecurityAttributes.OrderBy(a => a.AttributeType.FullName)) {
var attribute = new ICSharpCode.NRefactory.CSharp.Attribute(); var attribute = new ICSharpCode.NRefactory.CSharp.Attribute();
attribute.AddAnnotation(secAttribute); attribute.AddAnnotation(secAttribute);
attribute.Type = ConvertType(secAttribute.AttributeType); attribute.Type = ConvertType(secAttribute.AttributeType);

1
ILSpy/Languages/CSharpLanguage.cs

@ -381,7 +381,6 @@ namespace ICSharpCode.ILSpy
if (r.Name != "mscorlib") { if (r.Name != "mscorlib") {
w.WriteStartElement("Reference"); w.WriteStartElement("Reference");
w.WriteAttributeString("Include", r.Name); w.WriteAttributeString("Include", r.Name);
// TODO: RequiredTargetFramework
w.WriteEndElement(); w.WriteEndElement();
} }
} }

1
ILSpy/VB/VBLanguage.cs

@ -236,7 +236,6 @@ namespace ICSharpCode.ILSpy.VB
if (r.Name != "mscorlib") { if (r.Name != "mscorlib") {
w.WriteStartElement("Reference"); w.WriteStartElement("Reference");
w.WriteAttributeString("Include", r.Name); w.WriteAttributeString("Include", r.Name);
// TODO: RequiredTargetFramework
w.WriteEndElement(); w.WriteEndElement();
} }
} }

Loading…
Cancel
Save