本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol类的典型用法代码示例。如果您正苦于以下问题:C# MethodSymbol类的具体用法?C# MethodSymbol怎么用?C# MethodSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MethodSymbol类属于Microsoft.CodeAnalysis.CSharp.Symbols命名空间,在下文中一共展示了MethodSymbol类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Analyze
public static MultiDictionary<Symbol, CSharpSyntaxNode> Analyze(CSharpCompilation compilation, MethodSymbol method, BoundNode node)
{
var emptyStructs = new CaptureWalkerEmptyStructTypeCache();
var initiallyAssignedVariables = UnassignedVariablesWalker.Analyze(compilation, method, node, emptyStructs);
var walker = new IteratorAndAsyncCaptureWalker(compilation, method, node, emptyStructs, initiallyAssignedVariables);
bool badRegion = false;
walker.Analyze(ref badRegion);
Debug.Assert(!badRegion);
var result = walker.variablesCaptured;
if (!method.IsStatic && method.ContainingType.TypeKind == TypeKind.Struct)
{
// It is possible that the enclosing method only *writes* to the enclosing struct, but in that
// case it should be considered captured anyway so that we have a proxy for it to write to.
result.Add(method.ThisParameter, node.Syntax);
}
foreach (var variable in result.Keys.ToArray()) // take a snapshot, as we are modifying the underlying multidictionary
{
var local = variable as LocalSymbol;
if ((object)local != null && local.RefKind != RefKind.None)
{
walker.AddSpillsForRef(walker.refLocalInitializers[local], result[local]);
}
}
walker.Free();
return result;
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:33,代码来源:IteratorAndAsyncCaptureWalker.cs
示例2: Rewrite
/// <summary>
/// Rewrite an async method into a state machine type.
/// </summary>
internal static BoundStatement Rewrite(
BoundStatement body,
MethodSymbol method,
int methodOrdinal,
VariableSlotAllocator slotAllocatorOpt,
TypeCompilationState compilationState,
DiagnosticBag diagnostics,
out AsyncStateMachine stateMachineType)
{
if (!method.IsAsync)
{
stateMachineType = null;
return body;
}
// The CLR doesn't support adding fields to structs, so in order to enable EnC in an async method we need to generate a class.
var typeKind = compilationState.Compilation.Options.EnableEditAndContinue ? TypeKind.Class : TypeKind.Struct;
var bodyWithAwaitLifted = AwaitExpressionSpiller.Rewrite(body, method, compilationState, diagnostics);
stateMachineType = new AsyncStateMachine(slotAllocatorOpt, compilationState, method, methodOrdinal, typeKind);
compilationState.ModuleBuilderOpt.CompilationState.SetStateMachineType(method, stateMachineType);
var rewriter = new AsyncRewriter(bodyWithAwaitLifted, method, methodOrdinal, stateMachineType, slotAllocatorOpt, compilationState, diagnostics);
if (!rewriter.VerifyPresenceOfRequiredAPIs())
{
return body;
}
return rewriter.Rewrite();
}
开发者ID:RoryVL,项目名称:roslyn,代码行数:34,代码来源:AsyncRewriter.cs
示例3: LocalBinderFactory
private LocalBinderFactory(MethodSymbol method, Binder enclosing)
{
Debug.Assert((object)method != null);
_map = new SmallDictionary<CSharpSyntaxNode, Binder>(ReferenceEqualityComparer.Instance);
_method = method;
_enclosing = enclosing;
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:7,代码来源:LocalBinderFactory.cs
示例4: EELocalSymbol
public EELocalSymbol(
MethodSymbol method,
ImmutableArray<Location> locations,
string nameOpt,
int ordinal,
LocalDeclarationKind declarationKind,
TypeSymbol type,
RefKind refKind,
bool isPinned,
bool isCompilerGenerated,
bool canScheduleToStack)
{
Debug.Assert(method != null);
Debug.Assert(ordinal >= -1);
Debug.Assert(!locations.IsDefault);
Debug.Assert(type != null);
_method = method;
_locations = locations;
_nameOpt = nameOpt;
_ordinal = ordinal;
_declarationKind = declarationKind;
_type = type;
_refKind = refKind;
_isPinned = isPinned;
_isCompilerGenerated = isCompilerGenerated;
_canScheduleToStack = canScheduleToStack;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:28,代码来源:EELocalSymbol.cs
示例5: SourceAttributeData
internal SourceAttributeData(
SyntaxReference applicationNode,
NamedTypeSymbol attributeClass,
MethodSymbol attributeConstructor,
ImmutableArray<TypedConstant> constructorArguments,
ImmutableArray<int> constructorArgumentsSourceIndices,
ImmutableArray<KeyValuePair<string, TypedConstant>> namedArguments,
bool hasErrors,
bool isConditionallyOmitted)
{
Debug.Assert(!isConditionallyOmitted || (object)attributeClass != null && attributeClass.IsConditional);
Debug.Assert(!constructorArguments.IsDefault);
Debug.Assert(!namedArguments.IsDefault);
Debug.Assert(constructorArgumentsSourceIndices.IsDefault ||
constructorArgumentsSourceIndices.Any() && constructorArgumentsSourceIndices.Length == constructorArguments.Length);
this.attributeClass = attributeClass;
this.attributeConstructor = attributeConstructor;
this.constructorArguments = constructorArguments;
this.constructorArgumentsSourceIndices = constructorArgumentsSourceIndices;
this.namedArguments = namedArguments;
this.isConditionallyOmitted = isConditionallyOmitted;
this.hasErrors = hasErrors;
this.applicationNode = applicationNode;
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:25,代码来源:SourceAttributeData.cs
示例6: SynthesizedImplementationMethod
public SynthesizedImplementationMethod(
MethodSymbol interfaceMethod,
NamedTypeSymbol implementingType,
string name = null,
bool debuggerHidden = false,
PropertySymbol associatedProperty = null,
MethodSymbol asyncKickoffMethod = null)
{
//it does not make sense to add methods to substituted types
Debug.Assert(implementingType.IsDefinition);
this.name = name ?? ExplicitInterfaceHelpers.GetMemberName(interfaceMethod.Name, interfaceMethod.ContainingType, aliasQualifierOpt: null);
this.interfaceMethod = interfaceMethod;
this.implementingType = implementingType;
this.debuggerHidden = debuggerHidden;
this.associatedProperty = associatedProperty;
this.explicitInterfaceImplementations = ImmutableArray.Create<MethodSymbol>(interfaceMethod);
this.asyncKickoffMethod = asyncKickoffMethod;
// alpha-rename to get the implementation's type parameters
var typeMap = interfaceMethod.ContainingType.TypeSubstitution ?? TypeMap.Empty;
typeMap.WithAlphaRename(interfaceMethod, this, out this.typeParameters);
var substitutedInterfaceMethod = interfaceMethod.ConstructIfGeneric(this.typeParameters.Cast<TypeParameterSymbol, TypeSymbol>());
this.returnType = substitutedInterfaceMethod.ReturnType;
this.parameters = SynthesizedParameterSymbol.DeriveParameters(substitutedInterfaceMethod, this);
}
开发者ID:riversky,项目名称:roslyn,代码行数:27,代码来源:SynthesizedMethodSymbol.cs
示例7: Create
/// <summary>
/// Return the extension method in reduced form if the extension method
/// is applicable, and satisfies type parameter constraints, based on the
/// "this" argument type. Otherwise, returns null.
/// </summary>
public static MethodSymbol Create(MethodSymbol method, TypeSymbol receiverType, Compilation compilation)
{
Debug.Assert(method.IsExtensionMethod && method.MethodKind != MethodKind.ReducedExtension);
Debug.Assert(method.ParameterCount > 0);
Debug.Assert((object)receiverType != null);
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
method = method.InferExtensionMethodTypeArguments(receiverType, compilation, ref useSiteDiagnostics);
if ((object)method == null)
{
return null;
}
var conversions = new TypeConversions(method.ContainingAssembly.CorLibrary);
var conversion = conversions.ConvertExtensionMethodThisArg(method.Parameters[0].Type, receiverType, ref useSiteDiagnostics);
if (!conversion.Exists)
{
return null;
}
if (useSiteDiagnostics != null)
{
foreach (var diag in useSiteDiagnostics)
{
if (diag.Severity == DiagnosticSeverity.Error)
{
return null;
}
}
}
return Create(method);
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:39,代码来源:ReducedExtensionMethodSymbol.cs
示例8: BindFieldInitializers
internal static void BindFieldInitializers(
SourceMemberContainerTypeSymbol typeSymbol,
MethodSymbol scriptCtor,
ImmutableArray<FieldInitializers> fieldInitializers,
bool generateDebugInfo,
DiagnosticBag diagnostics,
ref ProcessedFieldInitializers processedInitializers) //by ref so that we can store the results of lowering
{
DiagnosticBag diagsForInstanceInitializers = DiagnosticBag.GetInstance();
try
{
ConsList<Imports> firstDebugImports;
processedInitializers.BoundInitializers = BindFieldInitializers(typeSymbol, scriptCtor, fieldInitializers,
diagsForInstanceInitializers, generateDebugInfo, out firstDebugImports);
processedInitializers.HasErrors = diagsForInstanceInitializers.HasAnyErrors();
processedInitializers.FirstDebugImports = firstDebugImports;
}
finally
{
diagnostics.AddRange(diagsForInstanceInitializers);
diagsForInstanceInitializers.Free();
}
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:25,代码来源:Binder_Initializers.cs
示例9: MakePropertyGetAccess
private BoundExpression MakePropertyGetAccess(
SyntaxNode syntax,
BoundExpression rewrittenReceiver,
PropertySymbol property,
ImmutableArray<BoundExpression> rewrittenArguments,
MethodSymbol getMethodOpt = null,
BoundPropertyAccess oldNodeOpt = null)
{
if (_inExpressionLambda && rewrittenArguments.IsEmpty)
{
return oldNodeOpt != null ?
oldNodeOpt.Update(rewrittenReceiver, property, LookupResultKind.Viable, property.Type) :
new BoundPropertyAccess(syntax, rewrittenReceiver, property, LookupResultKind.Viable, property.Type);
}
else
{
var getMethod = getMethodOpt ?? property.GetOwnOrInheritedGetMethod();
Debug.Assert((object)getMethod != null);
Debug.Assert(getMethod.ParameterCount == rewrittenArguments.Length);
Debug.Assert(((object)getMethodOpt == null) || ReferenceEquals(getMethod, getMethodOpt));
return BoundCall.Synthesized(
syntax,
rewrittenReceiver,
getMethod,
rewrittenArguments);
}
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:29,代码来源:LocalRewriter_PropertyAccess.cs
示例10: SynthesizedLambdaMethod
internal SynthesizedLambdaMethod(NamedTypeSymbol containingType, MethodSymbol topLevelMethod, BoundLambda node, bool isStatic, TypeCompilationState compilationState)
: base(containingType,
node.Symbol,
null,
node.SyntaxTree.GetReference(node.Body.Syntax),
node.Syntax.GetLocation(),
GeneratedNames.MakeLambdaMethodName(topLevelMethod.Name, compilationState.GenerateTempNumber()),
(containingType is LambdaFrame ? DeclarationModifiers.Internal : DeclarationModifiers.Private)
| (isStatic ? DeclarationModifiers.Static : 0)
| (node.Symbol.IsAsync ? DeclarationModifiers.Async : 0))
{
TypeMap typeMap;
ImmutableArray<TypeParameterSymbol> typeParameters;
LambdaFrame lambdaFrame;
if (!topLevelMethod.IsGenericMethod)
{
typeMap = TypeMap.Empty;
typeParameters = ImmutableArray<TypeParameterSymbol>.Empty;
}
else if ((object)(lambdaFrame = this.ContainingType as LambdaFrame) != null)
{
typeMap = lambdaFrame.TypeMap;
typeParameters = ImmutableArray<TypeParameterSymbol>.Empty;
}
else
{
typeMap = TypeMap.Empty.WithAlphaRename(topLevelMethod, this, out typeParameters);
}
AssignTypeMapAndTypeParameters(typeMap, typeParameters);
}
开发者ID:nagyist,项目名称:roslyn,代码行数:32,代码来源:LambdaRewriter.Frame.cs
示例11: MethodToStateMachineRewriter
public MethodToStateMachineRewriter(
SyntheticBoundNodeFactory F,
MethodSymbol originalMethod,
FieldSymbol state,
IReadOnlySet<Symbol> variablesCaptured,
IReadOnlyDictionary<Symbol, CapturedSymbolReplacement> nonReusableLocalProxies,
DiagnosticBag diagnostics,
bool useFinalizerBookkeeping)
: base(F.CompilationState, diagnostics)
{
Debug.Assert(F != null);
Debug.Assert(originalMethod != null);
Debug.Assert(state != null);
Debug.Assert(nonReusableLocalProxies != null);
Debug.Assert(diagnostics != null);
Debug.Assert(variablesCaptured != null);
this.F = F;
this.stateField = state;
this.cachedState = F.SynthesizedLocal(F.SpecialType(SpecialType.System_Int32), kind: SynthesizedLocalKind.StateMachineCachedState);
this.useFinalizerBookkeeping = useFinalizerBookkeeping;
this.hasFinalizerState = useFinalizerBookkeeping;
this.originalMethod = originalMethod;
this.variablesCaptured = variablesCaptured;
foreach (var proxy in nonReusableLocalProxies)
{
this.proxies.Add(proxy.Key, proxy.Value);
}
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:30,代码来源:MethodToStateMachineRewriter.cs
示例12: AsyncStruct
public AsyncStruct(MethodSymbol method)
: base(method, GeneratedNames.MakeIteratorOrAsyncDisplayClassName(method.Name, SequenceNumber(method)), TypeKind.Struct)
{
// TODO: report use-site errors on these types
this.interfaces = ImmutableArray.Create<NamedTypeSymbol>(method.DeclaringCompilation.GetWellKnownType(WellKnownType.System_Runtime_CompilerServices_IAsyncStateMachine));
this.constructor = new SynthesizedInstanceConstructor(this);
}
开发者ID:riversky,项目名称:roslyn,代码行数:7,代码来源:AsyncStruct.cs
示例13: ExecutableCodeBinder
internal ExecutableCodeBinder(CSharpSyntaxNode root, Symbol memberSymbol, Binder next, BinderFlags additionalFlags)
: base(next, (next.Flags | additionalFlags) & ~BinderFlags.AllClearedAtExecutableCodeBoundary)
{
this.memberSymbol = memberSymbol;
this.root = root;
this.owner = memberSymbol as MethodSymbol;
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:7,代码来源:ExecutableCodeBinder.cs
示例14: AppendImplicitReturn
// insert the implicit "return" statement at the end of the method body
// Normally, we wouldn't bother attaching syntax trees to compiler-generated nodes, but these
// ones are going to have sequence points.
internal static BoundBlock AppendImplicitReturn(BoundStatement node, MethodSymbol method = null, CSharpSyntaxNode syntax = null)
{
if (syntax == null)
{
syntax = node.Syntax;
}
BoundStatement ret =
(object)method != null && (object)method.IteratorElementType != null
? BoundYieldBreakStatement.Synthesized(syntax) as BoundStatement
: BoundReturnStatement.Synthesized(syntax, null);
if (syntax.Kind == SyntaxKind.Block)
{
var blockSyntax = (BlockSyntax)syntax;
ret = new BoundSequencePointWithSpan(
blockSyntax,
ret,
blockSyntax.CloseBraceToken.Span)
{ WasCompilerGenerated = true };
}
switch (node.Kind)
{
case BoundKind.Block:
var block = (BoundBlock)node;
return block.Update(block.LocalsOpt, block.Statements.Add(ret));
default:
return new BoundBlock(syntax, ImmutableArray<LocalSymbol>.Empty, ImmutableArray.Create(ret, node));
}
}
开发者ID:nagyist,项目名称:roslyn,代码行数:36,代码来源:FlowAnalysisPass.cs
示例15: GetEquivalentNodesMap
internal static Func<SyntaxNode, SyntaxNode> GetEquivalentNodesMap(MethodSymbol method1, MethodSymbol method0)
{
var tree1 = method1.Locations[0].SourceTree;
var tree0 = method0.Locations[0].SourceTree;
Assert.NotEqual(tree1, tree0);
var locals0 = GetAllLocals(method0);
return s =>
{
var s1 = s;
Assert.Equal(s1.SyntaxTree, tree1);
foreach (var s0 in locals0)
{
if (!SyntaxFactory.AreEquivalent(s0, s1))
{
continue;
}
// Make sure the containing statements are the same.
var p0 = GetNearestStatement(s0);
var p1 = GetNearestStatement(s1);
if (SyntaxFactory.AreEquivalent(p0, p1))
{
return s0;
}
}
return null;
};
}
开发者ID:elemk0vv,项目名称:roslyn-1,代码行数:28,代码来源:EditAndContinueTestBase.cs
示例16: ForEachEnumeratorInfo
private ForEachEnumeratorInfo(
TypeSymbol collectionType,
TypeSymbol elementType,
MethodSymbol getEnumeratorMethod,
MethodSymbol currentPropertyGetter,
MethodSymbol moveNextMethod,
bool needsDisposeMethod,
Conversion collectionConversion,
Conversion currentConversion,
Conversion enumeratorConversion,
BinderFlags location)
{
Debug.Assert((object)collectionType != null, "Field 'collectionType' cannot be null");
Debug.Assert((object)elementType != null, "Field 'elementType' cannot be null");
Debug.Assert((object)getEnumeratorMethod != null, "Field 'getEnumeratorMethod' cannot be null");
Debug.Assert((object)currentPropertyGetter != null, "Field 'currentPropertyGetter' cannot be null");
Debug.Assert((object)moveNextMethod != null, "Field 'moveNextMethod' cannot be null");
this.CollectionType = collectionType;
this.ElementType = elementType;
this.GetEnumeratorMethod = getEnumeratorMethod;
this.CurrentPropertyGetter = currentPropertyGetter;
this.MoveNextMethod = moveNextMethod;
this.NeedsDisposeMethod = needsDisposeMethod;
this.CollectionConversion = collectionConversion;
this.CurrentConversion = currentConversion;
this.EnumeratorConversion = enumeratorConversion;
this.Location = location;
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:29,代码来源:ForEachEnumeratorInfo.cs
示例17: StateMachineRewriter
protected StateMachineRewriter(
BoundStatement body,
MethodSymbol method,
SynthesizedContainer stateMachineType,
VariableSlotAllocator slotAllocatorOpt,
TypeCompilationState compilationState,
DiagnosticBag diagnostics)
{
Debug.Assert(body != null);
Debug.Assert(method != null);
Debug.Assert(stateMachineType != null);
Debug.Assert(compilationState != null);
Debug.Assert(diagnostics != null);
this.body = body;
this.method = method;
this.stateMachineType = stateMachineType;
this.slotAllocatorOpt = slotAllocatorOpt;
this.synthesizedLocalOrdinals = new SynthesizedLocalOrdinalsDispenser();
this.diagnostics = diagnostics;
this.F = new SyntheticBoundNodeFactory(method, body.Syntax, compilationState, diagnostics);
Debug.Assert(F.CurrentType == method.ContainingType);
Debug.Assert(F.Syntax == body.Syntax);
}
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:25,代码来源:StateMachineRewriter.cs
示例18: AsyncMethodToStateMachineRewriter
internal AsyncMethodToStateMachineRewriter(
MethodSymbol method,
int methodOrdinal,
AsyncMethodBuilderMemberCollection asyncMethodBuilderMemberCollection,
SyntheticBoundNodeFactory F,
FieldSymbol state,
FieldSymbol builder,
IReadOnlySet<Symbol> hoistedVariables,
IReadOnlyDictionary<Symbol, CapturedSymbolReplacement> nonReusableLocalProxies,
SynthesizedLocalOrdinalsDispenser synthesizedLocalOrdinals,
VariableSlotAllocator slotAllocatorOpt,
int nextFreeHoistedLocalSlot,
DiagnosticBag diagnostics)
: base(F, method, state, hoistedVariables, nonReusableLocalProxies, synthesizedLocalOrdinals, slotAllocatorOpt, nextFreeHoistedLocalSlot, diagnostics, useFinalizerBookkeeping: false)
{
_method = method;
_asyncMethodBuilderMemberCollection = asyncMethodBuilderMemberCollection;
_asyncMethodBuilderField = builder;
_exprReturnLabel = F.GenerateLabel("exprReturn");
_exitLabel = F.GenerateLabel("exitLabel");
_exprRetValue = method.IsGenericTaskReturningAsync(F.Compilation)
? F.SynthesizedLocal(asyncMethodBuilderMemberCollection.ResultType, syntax: F.Syntax, kind: SynthesizedLocalKind.AsyncMethodReturnValue)
: null;
_dynamicFactory = new LoweredDynamicOperationFactory(F, methodOrdinal);
_awaiterFields = new Dictionary<TypeSymbol, FieldSymbol>(TypeSymbol.EqualsIgnoringDynamicComparer);
_nextAwaiterId = slotAllocatorOpt?.PreviousAwaiterSlotCount ?? 0;
}
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:29,代码来源:AsyncMethodToStateMachineRewriter.cs
示例19: PlaceholderLocalBinder
internal PlaceholderLocalBinder(
CSharpSyntaxNode syntax,
ImmutableArray<Alias> aliases,
MethodSymbol containingMethod,
EETypeNameDecoder typeNameDecoder,
Binder next) :
base(next)
{
_syntax = syntax;
_containingMethod = containingMethod;
var compilation = next.Compilation;
var sourceAssembly = compilation.SourceAssembly;
var aliasesBuilder = ArrayBuilder<LocalSymbol>.GetInstance(aliases.Length);
var lowercaseBuilder = ImmutableDictionary.CreateBuilder<string, LocalSymbol>();
foreach (Alias alias in aliases)
{
var local = PlaceholderLocalSymbol.Create(
typeNameDecoder,
containingMethod,
sourceAssembly,
alias);
aliasesBuilder.Add(local);
if (alias.Kind == DkmClrAliasKind.ReturnValue)
{
lowercaseBuilder.Add(local.Name.ToLower(), local);
}
}
_lowercaseReturnValueAliases = lowercaseBuilder.ToImmutableDictionary();
_aliases = aliasesBuilder.ToImmutableAndFree();
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:33,代码来源:PlaceholderLocalBinder.cs
示例20: SynthesizedExplicitImplementationMethod
public SynthesizedExplicitImplementationMethod(
MethodSymbol interfaceMethod,
MethodSymbol implementingMethod,
NamedTypeSymbol implementingType) : base(interfaceMethod, implementingType)
{
this.implementingMethod = implementingMethod;
}
开发者ID:riversky,项目名称:roslyn,代码行数:7,代码来源:SynthesizedExplicitImplementationMethod.cs
注:本文中的Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论