Beispiel #1
0
 void IAstTransform.Run(AstNode node, TransformContext context)
 {
     node.AcceptVisitor(this);
 }
Beispiel #2
0
 public void Run(AstNode compilationUnit, TransformContext context)
 {
     compilationUnit.AcceptVisitor(this);
 }
 public void Run(AstNode rootNode, TransformContext context)
 {
     this.context    = context;
     this.usingScope = this.rootUsingScope = rootNode.Annotation <UsingScope>();
     rootNode.AcceptVisitor(this);
 }
Beispiel #4
0
 public ConvertConstructorCallIntoInitializerVisitor(TransformContext context)
 {
     Debug.Assert(context != null);
     this.context = context;
 }
 public FindRequiredImports(TransformContext context)
 {
     this.currentNamespace = context.DecompiledTypeDefinition?.Namespace ?? string.Empty;
 }
 public void Run(AstNode rootNode, TransformContext context)
 {
     this.context = context;
     InitializeContext(rootNode.Annotation <UsingScope>());
     rootNode.AcceptVisitor(this);
 }
        public void Run(AstNode rootNode, TransformContext context)
        {
            foreach (var section in rootNode.Children.OfType <AttributeSection>())
            {
                if (section.AttributeTarget == "assembly")
                {
                    foreach (var attribute in section.Attributes)
                    {
                        var trr = attribute.Type.Annotation <TypeResolveResult>();
                        if (trr == null)
                        {
                            continue;
                        }

                        string fullName  = trr.Type.FullName;
                        var    arguments = attribute.Arguments;
                        switch (fullName)
                        {
                        case "System.Diagnostics.DebuggableAttribute":
                        {
                            attribute.Remove();
                            break;
                        }

                        case "System.Runtime.CompilerServices.CompilationRelaxationsAttribute":
                        {
                            if (arguments.Count == 1 && arguments.First() is PrimitiveExpression expr && expr.Value is int value && value == 8)
                            {
                                attribute.Remove();
                            }
                            break;
                        }

                        case "System.Runtime.CompilerServices.RuntimeCompatibilityAttribute":
                        {
                            if (arguments.Count != 1)
                            {
                                break;
                            }
                            if (!(arguments.First() is NamedExpression expr1) || expr1.Name != "WrapNonExceptionThrows")
                            {
                                break;
                            }
                            if (!(expr1.Expression is PrimitiveExpression expr2) || !(expr2.Value is bool value) || value != true)
                            {
                                break;
                            }
                            attribute.Remove();
                            break;
                        }

                        case "System.Runtime.Versioning.TargetFrameworkAttribute":
                        {
                            attribute.Remove();
                            break;
                        }

                        case "System.Security.Permissions.SecurityPermissionAttribute":
                        {
                            if (arguments.Count != 2)
                            {
                                break;
                            }
                            if (!(arguments.First() is MemberReferenceExpression expr1) || expr1.MemberName != "RequestMinimum")
                            {
                                break;
                            }
                            if (!(expr1.NextSibling is NamedExpression expr2) || expr2.Name != "SkipVerification")
                            {
                                break;
                            }
                            if (!(expr2.Expression is PrimitiveExpression expr3) || !(expr3.Value is bool value2) || value2 != true)
                            {
                                break;
                            }
                            attribute.Remove();
                            break;
                        }
                        }
                    }
                }
                else if (section.AttributeTarget == "module")
                {
                    foreach (var attribute in section.Attributes)
                    {
                        var trr = attribute.Type.Annotation <TypeResolveResult>();
                        if (trr == null)
                        {
                            continue;
                        }

                        switch (trr.Type.FullName)
                        {
                        case "System.Security.UnverifiableCodeAttribute":
                            attribute.Remove();
                            break;
                        }
                    }
                }
                else
                {
                    continue;
                }

                if (section.Attributes.Count == 0)
                {
                    section.Remove();
                }
            }
        }
 public void Run(AstNode rootNode, TransformContext context)
 {
     rootNode.AcceptVisitor(this);
 }
Beispiel #9
0
 protected void Initialize(TransformContext context)
 {
     currentTypeDefinition = context.DecompiledTypeDefinition;
     currentMethod         = context.DecompiledMember as IMethod;
 }