From 6d22ff99ad5c6ab74eeac334760ccb64078ec6ea Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 18 Sep 2011 17:02:34 +0200 Subject: [PATCH] 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. --- ICSharpCode.Decompiler/Ast/AstBuilder.cs | 6 +++--- ILSpy/Languages/CSharpLanguage.cs | 1 - ILSpy/VB/VBLanguage.cs | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ICSharpCode.Decompiler/Ast/AstBuilder.cs b/ICSharpCode.Decompiler/Ast/AstBuilder.cs index fa06003b2..f7d89b152 100644 --- a/ICSharpCode.Decompiler/Ast/AstBuilder.cs +++ b/ICSharpCode.Decompiler/Ast/AstBuilder.cs @@ -1317,7 +1317,7 @@ namespace ICSharpCode.Decompiler.Ast { if (customAttributeProvider.HasCustomAttributes) { var attributes = new List(); - 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") { // don't show the ExtensionAttribute (it's converted to the 'this' modifier) continue; @@ -1387,8 +1387,8 @@ namespace ICSharpCode.Decompiler.Ast if (!secDeclProvider.HasSecurityDeclarations) return; var attributes = new List(); - foreach (var secDecl in secDeclProvider.SecurityDeclarations) { - foreach (var secAttribute in secDecl.SecurityAttributes) { + foreach (var secDecl in secDeclProvider.SecurityDeclarations.OrderBy(d => d.Action)) { + foreach (var secAttribute in secDecl.SecurityAttributes.OrderBy(a => a.AttributeType.FullName)) { var attribute = new ICSharpCode.NRefactory.CSharp.Attribute(); attribute.AddAnnotation(secAttribute); attribute.Type = ConvertType(secAttribute.AttributeType); diff --git a/ILSpy/Languages/CSharpLanguage.cs b/ILSpy/Languages/CSharpLanguage.cs index 53cc3892c..a2e303b9b 100644 --- a/ILSpy/Languages/CSharpLanguage.cs +++ b/ILSpy/Languages/CSharpLanguage.cs @@ -381,7 +381,6 @@ namespace ICSharpCode.ILSpy if (r.Name != "mscorlib") { w.WriteStartElement("Reference"); w.WriteAttributeString("Include", r.Name); - // TODO: RequiredTargetFramework w.WriteEndElement(); } } diff --git a/ILSpy/VB/VBLanguage.cs b/ILSpy/VB/VBLanguage.cs index 095c2390d..152b7dbe0 100644 --- a/ILSpy/VB/VBLanguage.cs +++ b/ILSpy/VB/VBLanguage.cs @@ -236,7 +236,6 @@ namespace ICSharpCode.ILSpy.VB if (r.Name != "mscorlib") { w.WriteStartElement("Reference"); w.WriteAttributeString("Include", r.Name); - // TODO: RequiredTargetFramework w.WriteEndElement(); } }