/// <summary> /// Normalizes the <paramref name="methodDeclaration" />. /// </summary> /// <param name="methodDeclaration">The method declaration that should be normalized.</param> public override SyntaxNode VisitMethodDeclaration(MethodDeclarationSyntax methodDeclaration) { if (!methodDeclaration.RequiresBoundTreeGeneration(SemanticModel)) return methodDeclaration; var methodSymbol = methodDeclaration.GetMethodSymbol(SemanticModel); var methodBody = _implementationMethods[GetMethodKey(methodSymbol)]; var metadataMethodName = (methodDeclaration.Identifier.ValueText + "MethodBody" + _methodCount++).ToSynthesized(); var metadataMethod = Syntax.MethodDeclaration( name: metadataMethodName, returnType: Syntax.TypeExpression(Compilation.GetTypeSymbol<MethodBodyMetadata>()), accessibility: Accessibility.Private, statements: methodBody.Statements); var suppressAttribute = Syntax.Attribute(typeof(SuppressTransformationAttribute).FullName); var compilerGeneratedAttribute = Syntax.Attribute(typeof(CompilerGeneratedAttribute).FullName); metadataMethod = Syntax.AddAttributes(metadataMethod, suppressAttribute, compilerGeneratedAttribute); AddMembers(methodSymbol.ContainingType, (MethodDeclarationSyntax)metadataMethod); var metadataAttribute = Syntax.Attribute(typeof(MethodBodyMetadataAttribute).FullName, Syntax.LiteralExpression(metadataMethodName)); return Syntax.AddAttributes(methodDeclaration, metadataAttribute); }