private static BlockSyntax GenerateBlock(IMethodSymbol accessor) { return(SyntaxFactory.Block( StatementGenerator.GenerateStatements( CodeGenerationMethodInfo.GetStatements(accessor) ) )); }
internal static BlockSyntax GenerateBlock(IMethodSymbol method) { return(SyntaxFactory.Block( StatementGenerator.GenerateStatements( CodeGenerationMethodInfo.GetStatements(method) ) )); }
private static SyntaxTokenList GenerateModifiers( IMethodSymbol method, CodeGenerationDestination destination, CodeGenerationOptions options) { var tokens = new List <SyntaxToken>(); // Only "unsafe" modifier allowed if we're an explicit impl. if (method.ExplicitInterfaceImplementations.Any()) { if (CodeGenerationMethodInfo.GetIsUnsafe(method)) { tokens.Add(SyntaxFactory.Token(SyntaxKind.UnsafeKeyword)); } } else { // If we're generating into an interface, then we don't use any modifiers. if (destination != CodeGenerationDestination.CompilationUnit && destination != CodeGenerationDestination.Namespace && destination != CodeGenerationDestination.InterfaceType) { AddAccessibilityModifiers(method.DeclaredAccessibility, tokens, options, Accessibility.Private); if (method.IsAbstract) { tokens.Add(SyntaxFactory.Token(SyntaxKind.AbstractKeyword)); } if (method.IsSealed) { tokens.Add(SyntaxFactory.Token(SyntaxKind.SealedKeyword)); } if (method.IsStatic) { tokens.Add(SyntaxFactory.Token(SyntaxKind.StaticKeyword)); } if (method.IsOverride) { tokens.Add(SyntaxFactory.Token(SyntaxKind.OverrideKeyword)); } if (method.IsVirtual) { tokens.Add(SyntaxFactory.Token(SyntaxKind.VirtualKeyword)); } if (CodeGenerationMethodInfo.GetIsPartial(method) && !method.IsAsync) { tokens.Add(SyntaxFactory.Token(SyntaxKind.PartialKeyword)); } } if (CodeGenerationMethodInfo.GetIsUnsafe(method)) { tokens.Add(SyntaxFactory.Token(SyntaxKind.UnsafeKeyword)); } if (CodeGenerationMethodInfo.GetIsNew(method)) { tokens.Add(SyntaxFactory.Token(SyntaxKind.NewKeyword)); } } if (destination != CodeGenerationDestination.InterfaceType) { if (CodeGenerationMethodInfo.GetIsAsync(method)) { tokens.Add(SyntaxFactory.Token(SyntaxKind.AsyncKeyword)); } } if (CodeGenerationMethodInfo.GetIsPartial(method) && method.IsAsync) { tokens.Add(SyntaxFactory.Token(SyntaxKind.PartialKeyword)); } return(tokens.ToSyntaxTokenList()); }