/// <summary> /// Creates a method symbol that can be used to describe an operator declaration. /// </summary> public static IMethodSymbol CreateOperatorSymbol( ImmutableArray <AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, ITypeSymbol returnType, CodeGenerationOperatorKind operatorKind, ImmutableArray <IParameterSymbol> parameters, ImmutableArray <SyntaxNode> statements = default, ImmutableArray <AttributeData> returnTypeAttributes = default) { var expectedParameterCount = CodeGenerationOperatorSymbol.GetParameterCount(operatorKind); if (parameters.Length != expectedParameterCount) { var message = expectedParameterCount == 1 ? WorkspacesResources.Invalid_number_of_parameters_for_unary_operator : WorkspacesResources.Invalid_number_of_parameters_for_binary_operator; throw new ArgumentException(message, nameof(parameters)); } var result = new CodeGenerationOperatorSymbol(null, attributes, accessibility, modifiers, returnType, operatorKind, parameters, returnTypeAttributes); CodeGenerationMethodInfo.Attach(result, modifiers.IsNew, modifiers.IsUnsafe, modifiers.IsPartial, modifiers.IsAsync, statements, handlesExpressions: default); return(result); }
/// <summary> /// Creates a method symbol that can be used to describe a conversion declaration. /// </summary> public static IMethodSymbol CreateConversionSymbol(IList <AttributeData> attributes, Accessibility accessibility, SymbolModifiers modifiers, ITypeSymbol toType, IParameterSymbol fromType, bool isImplicit = false, IList <SyntaxNode> statements = null, IList <AttributeData> toTypeAttributes = null) { var result = new CodeGenerationConversionSymbol(null, attributes, accessibility, modifiers, toType, fromType, isImplicit, toTypeAttributes); CodeGenerationMethodInfo.Attach(result, modifiers.IsNew, modifiers.IsUnsafe, modifiers.IsPartial, modifiers.IsAsync, statements, handlesExpressions: null); return(result); }
internal static IMethodSymbol CreateMethodSymbol(INamedTypeSymbol containingType, IList <AttributeData> attributes, Accessibility accessibility, SymbolModifiers modifiers, ITypeSymbol returnType, IMethodSymbol explicitInterfaceSymbol, string name, IList <ITypeParameterSymbol> typeParameters, IList <IParameterSymbol> parameters, IList <SyntaxNode> statements = null, IList <SyntaxNode> handlesExpressions = null, IList <AttributeData> returnTypeAttributes = null) { var result = new CodeGenerationMethodSymbol(containingType, attributes, accessibility, modifiers, returnType, explicitInterfaceSymbol, name, typeParameters, parameters, returnTypeAttributes); CodeGenerationMethodInfo.Attach(result, modifiers.IsNew, modifiers.IsUnsafe, modifiers.IsPartial, modifiers.IsAsync, statements, handlesExpressions); return(result); }
protected override CodeGenerationSymbol Clone() { var result = new CodeGenerationMethodSymbol( this.ContainingType, this.GetAttributes(), this.DeclaredAccessibility, this.Modifiers, this.ReturnType, this.RefKind, this.ExplicitInterfaceImplementations, this.Name, this.TypeParameters, this.Parameters, this.GetReturnTypeAttributes(), _documentationCommentXml, this.MethodKind, this.IsInitOnly ); CodeGenerationMethodInfo.Attach( result, CodeGenerationMethodInfo.GetIsNew(this), CodeGenerationMethodInfo.GetIsUnsafe(this), CodeGenerationMethodInfo.GetIsPartial(this), CodeGenerationMethodInfo.GetIsAsyncMethod(this), CodeGenerationMethodInfo.GetStatements(this), CodeGenerationMethodInfo.GetHandlesExpressions(this) ); return(result); }
public static void Attach( IMethodSymbol method, bool isNew, bool isUnsafe, bool isPartial, bool isAsync, IList<SyntaxNode> statements, IList<SyntaxNode> handlesExpressions) { var info = new CodeGenerationMethodInfo(isNew, isUnsafe, isPartial, isAsync, statements, handlesExpressions); s_methodToInfoMap.Add(method, info); }
public static void Attach( IMethodSymbol method, bool isNew, bool isUnsafe, bool isPartial, bool isAsync, IList <SyntaxNode> statements, IList <SyntaxNode> handlesExpressions) { var info = new CodeGenerationMethodInfo(isNew, isUnsafe, isPartial, isAsync, statements, handlesExpressions); methodToInfoMap.Add(method, info); }
internal static IMethodSymbol CreateMethodSymbol( INamedTypeSymbol?containingType, ImmutableArray <AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, ITypeSymbol?returnType, RefKind refKind, ImmutableArray <IMethodSymbol> explicitInterfaceImplementations, string name, ImmutableArray <ITypeParameterSymbol> typeParameters, ImmutableArray <IParameterSymbol> parameters, ImmutableArray <SyntaxNode> statements = default, ImmutableArray <SyntaxNode> handlesExpressions = default, ImmutableArray <AttributeData> returnTypeAttributes = default, MethodKind methodKind = MethodKind.Ordinary, bool isInitOnly = false ) { var result = new CodeGenerationMethodSymbol( containingType, attributes, accessibility, modifiers, returnType, refKind, explicitInterfaceImplementations, name, typeParameters, parameters, returnTypeAttributes, documentationCommentXml: null, methodKind, isInitOnly ); CodeGenerationMethodInfo.Attach( result, modifiers.IsNew, modifiers.IsUnsafe, modifiers.IsPartial, modifiers.IsAsync, statements, handlesExpressions ); return(result); }
/// <summary> /// Creates a method symbol that can be used to describe an operator declaration. /// </summary> public static IMethodSymbol CreateOperatorSymbol(IList <AttributeData> attributes, Accessibility accessibility, SymbolModifiers modifiers, ITypeSymbol returnType, CodeGenerationOperatorKind operatorKind, IList <IParameterSymbol> parameters, IList <SyntaxNode> statements = null, IList <AttributeData> returnTypeAttributes = null) { int expectedParameterCount = CodeGenerationOperatorSymbol.GetParameterCount(operatorKind); if (parameters.Count != expectedParameterCount) { var message = expectedParameterCount == 1 ? WorkspacesResources.InvalidParameterCountForUnaryOperator : WorkspacesResources.InvalidParameterCountForBinaryOperator; throw new ArgumentException(message, "parameters"); } var result = new CodeGenerationOperatorSymbol(null, attributes, accessibility, modifiers, returnType, operatorKind, parameters, returnTypeAttributes); CodeGenerationMethodInfo.Attach(result, modifiers.IsNew, modifiers.IsUnsafe, modifiers.IsPartial, modifiers.IsAsync, statements, handlesExpressions: null); return(result); }
protected override CodeGenerationSymbol Clone() { var result = new CodeGenerationMethodSymbol(this.ContainingType, this.GetAttributes(), this.DeclaredAccessibility, this.Modifiers, this.ReturnType, this.ExplicitInterfaceImplementations.FirstOrDefault(), this.Name, this.TypeParameters, this.Parameters, this.GetReturnTypeAttributes()); CodeGenerationMethodInfo.Attach(result, CodeGenerationMethodInfo.GetIsNew(this), CodeGenerationMethodInfo.GetIsUnsafe(this), CodeGenerationMethodInfo.GetIsPartial(this), CodeGenerationMethodInfo.GetIsAsync(this), CodeGenerationMethodInfo.GetStatements(this), CodeGenerationMethodInfo.GetHandlesExpressions(this)); return result; }
internal static IMethodSymbol CreateMethodSymbol( INamedTypeSymbol containingType, ImmutableArray <AttributeData> attributes, Accessibility accessibility, DeclarationModifiers modifiers, ITypeSymbol returnType, bool returnsByRef, IMethodSymbol explicitInterfaceSymbol, string name, ImmutableArray <ITypeParameterSymbol> typeParameters, ImmutableArray <IParameterSymbol> parameters, ImmutableArray <SyntaxNode> statements = default(ImmutableArray <SyntaxNode>), ImmutableArray <SyntaxNode> handlesExpressions = default(ImmutableArray <SyntaxNode>), ImmutableArray <AttributeData> returnTypeAttributes = default(ImmutableArray <AttributeData>), MethodKind methodKind = MethodKind.Ordinary) { var result = new CodeGenerationMethodSymbol(containingType, attributes, accessibility, modifiers, returnType, returnsByRef, explicitInterfaceSymbol, name, typeParameters, parameters, returnTypeAttributes, methodKind); CodeGenerationMethodInfo.Attach(result, modifiers.IsNew, modifiers.IsUnsafe, modifiers.IsPartial, modifiers.IsAsync, statements, handlesExpressions); return(result); }
private static bool GetIsAsync(CodeGenerationMethodInfo info) { return(info != null && info.isAsync); }
private static ImmutableArray <SyntaxNode> GetStatements(CodeGenerationMethodInfo info) => info?._statements ?? ImmutableArray <SyntaxNode> .Empty;
private static bool GetIsUnsafe(CodeGenerationMethodInfo info) { return(info != null && info.isUnsafe); }
private static bool GetIsPartial(CodeGenerationMethodInfo info) { return(info != null && info.isPartial); }
private static ImmutableArray <SyntaxNode> GetHandlesExpressions(CodeGenerationMethodInfo info) => info?._handlesExpressions ?? ImmutableArray <SyntaxNode> .Empty;
private static bool GetIsNew(CodeGenerationMethodInfo info) { return(info != null && info.isNew); }
private static bool GetIsPartial(CodeGenerationMethodInfo info) => info != null && info._isPartial;
private static bool GetIsUnsafe(CodeGenerationMethodInfo info) { return info != null && info._isUnsafe; }
private static bool GetIsAsync(CodeGenerationMethodInfo info) { return info != null && info._isAsync; }
private static bool GetIsAsync(CodeGenerationMethodInfo info) => info != null && info._isAsync;
private static IList<SyntaxNode> GetHandlesExpressions(CodeGenerationMethodInfo info) { return info == null ? SpecializedCollections.EmptyList<SyntaxNode>() : info._handlesExpressions; }
private static bool GetIsNew(CodeGenerationMethodInfo info) { return info != null && info._isNew; }
private static IList<SyntaxNode> GetStatements(CodeGenerationMethodInfo info) { return info == null ? SpecializedCollections.EmptyList<SyntaxNode>() : info._statements; }
private static IList <SyntaxNode> GetStatements(CodeGenerationMethodInfo info) { return(info == null ? SpecializedCollections.EmptyList <SyntaxNode>() : info.statements); }
private static bool GetIsUnsafe(CodeGenerationMethodInfo info) => info != null && info._isUnsafe;
private static IList <SyntaxNode> GetHandlesExpressions(CodeGenerationMethodInfo info) { return(info == null ? SpecializedCollections.EmptyList <SyntaxNode>() : info.handlesExpressions); }
private static bool GetIsPartial(CodeGenerationMethodInfo info) { return info != null && info._isPartial; }