From 45e327d53ab4d2a5d3ce27e7c334b395c483282b Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 1 Jun 2012 15:22:06 +0200 Subject: [PATCH] Don't show [AsyncStateMachine] attribute. --- ICSharpCode.Decompiler/Ast/AstBuilder.cs | 12 ++++++++---- ICSharpCode.Decompiler/Tests/PropertiesAndEvents.cs | 2 +- ILSpy.sln | 10 +++++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ICSharpCode.Decompiler/Ast/AstBuilder.cs b/ICSharpCode.Decompiler/Ast/AstBuilder.cs index b8d65759e..a95ddbaf2 100644 --- a/ICSharpCode.Decompiler/Ast/AstBuilder.cs +++ b/ICSharpCode.Decompiler/Ast/AstBuilder.cs @@ -1348,6 +1348,7 @@ namespace ICSharpCode.Decompiler.Ast static void ConvertCustomAttributes(AstNode attributedNode, ICustomAttributeProvider customAttributeProvider, string attributeTarget = null) { + EntityDeclaration entityDecl = attributedNode as EntityDeclaration; if (customAttributeProvider.HasCustomAttributes) { var attributes = new List(); foreach (var customAttribute in customAttributeProvider.CustomAttributes.OrderBy(a => a.AttributeType.FullName)) { @@ -1359,11 +1360,14 @@ namespace ICSharpCode.Decompiler.Ast // don't show the ParamArrayAttribute (it's converted to the 'params' modifier) continue; } - if (customAttribute.AttributeType.Name == "DebuggerStepThroughAttribute" && customAttribute.AttributeType.Namespace == "System.Diagnostics") { - // don't show the attribute if the method is async - EntityDeclaration entityDecl = attributedNode as EntityDeclaration; - if (entityDecl != null && entityDecl.HasModifier(Modifiers.Async)) + // if the method is async, remove [DebuggerStepThrough] and [Async + if (entityDecl != null && entityDecl.HasModifier(Modifiers.Async)) { + if (customAttribute.AttributeType.Name == "DebuggerStepThroughAttribute" && customAttribute.AttributeType.Namespace == "System.Diagnostics") { continue; + } + if (customAttribute.AttributeType.Name == "AsyncStateMachineAttribute" && customAttribute.AttributeType.Namespace == "System.Runtime.CompilerServices") { + continue; + } } var attribute = new ICSharpCode.NRefactory.CSharp.Attribute(); diff --git a/ICSharpCode.Decompiler/Tests/PropertiesAndEvents.cs b/ICSharpCode.Decompiler/Tests/PropertiesAndEvents.cs index bdc4f7dd1..9b3d16589 100644 --- a/ICSharpCode.Decompiler/Tests/PropertiesAndEvents.cs +++ b/ICSharpCode.Decompiler/Tests/PropertiesAndEvents.cs @@ -24,7 +24,7 @@ public class PropertiesAndEvents public event EventHandler AutomaticEvent; [field: NonSerialized] - public event EventHandler AutomaticEventWithInitializer = delegate + public event EventHandler AutomaticEventWithInitializer = delegate(object sender, EventArgs e) { }; diff --git a/ILSpy.sln b/ILSpy.sln index 82285a7ff..408ed9f56 100644 --- a/ILSpy.sln +++ b/ILSpy.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.2.0.8657-Beta 2 +# SharpDevelop 4.3.0.8807-alpha Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{F45DB999-7E72-4000-B5AD-3A7B485A0896}" ProjectSection(SolutionItems) = postProject doc\Command Line.txt = doc\Command Line.txt @@ -171,6 +171,14 @@ Global {53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|Any CPU.ActiveCfg = Release|Any CPU {53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|x86.Build.0 = Release|Any CPU {53DCA265-3C3C-42F9-B647-F72BA678122B}.Release|x86.ActiveCfg = Release|Any CPU + {1D18D788-F7EE-4585-A23B-34DC8EC63CB8}.Debug|x86.Build.0 = Debug|Any CPU + {1D18D788-F7EE-4585-A23B-34DC8EC63CB8}.Debug|x86.ActiveCfg = Debug|Any CPU + {1D18D788-F7EE-4585-A23B-34DC8EC63CB8}.Release|x86.Build.0 = Release|Any CPU + {1D18D788-F7EE-4585-A23B-34DC8EC63CB8}.Release|x86.ActiveCfg = Release|Any CPU + {6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A}.Debug|x86.Build.0 = Debug|Any CPU + {6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A}.Debug|x86.ActiveCfg = Debug|Any CPU + {6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A}.Release|x86.Build.0 = Release|Any CPU + {6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE