本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol.ConstructIfGeneric方法的典型用法代码示例。如果您正苦于以下问题:C# MethodSymbol.ConstructIfGeneric方法的具体用法?C# MethodSymbol.ConstructIfGeneric怎么用?C# MethodSymbol.ConstructIfGeneric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CodeAnalysis.CSharp.Symbols.MethodSymbol
的用法示例。
在下文中一共展示了MethodSymbol.ConstructIfGeneric方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SynthesizedImplementationMethod
public SynthesizedImplementationMethod(
MethodSymbol interfaceMethod,
NamedTypeSymbol implementingType,
string name = null,
bool generateDebugInfo = true,
PropertySymbol associatedProperty = null)
{
//it does not make sense to add methods to substituted types
Debug.Assert(implementingType.IsDefinition);
_name = name ?? ExplicitInterfaceHelpers.GetMemberName(interfaceMethod.Name, interfaceMethod.ContainingType, aliasQualifierOpt: null);
_interfaceMethod = interfaceMethod;
_implementingType = implementingType;
_generateDebugInfo = generateDebugInfo;
_associatedProperty = associatedProperty;
_explicitInterfaceImplementations = ImmutableArray.Create<MethodSymbol>(interfaceMethod);
// alpha-rename to get the implementation's type parameters
var typeMap = interfaceMethod.ContainingType.TypeSubstitution ?? TypeMap.Empty;
typeMap.WithAlphaRename(interfaceMethod, this, out _typeParameters);
var substitutedInterfaceMethod = interfaceMethod.ConstructIfGeneric(_typeParameters.Cast<TypeParameterSymbol, TypeSymbol>());
_returnType = substitutedInterfaceMethod.ReturnType;
_parameters = SynthesizedParameterSymbol.DeriveParameters(substitutedInterfaceMethod, this);
}
示例2: 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);
}
示例3: TupleMethodSymbol
public TupleMethodSymbol(TupleTypeSymbol container, MethodSymbol underlyingMethod)
{
Debug.Assert(underlyingMethod.ConstructedFrom == (object)underlyingMethod);
_containingType = container;
TypeMap.Empty.WithAlphaRename(underlyingMethod, this, out _typeParameters);
_underlyingMethod = underlyingMethod.ConstructIfGeneric(TypeArguments);
}
示例4: CopyMethodCustomModifiers
/// <remarks>
/// Out params are updated by assignment. If you require thread-safety, pass temps and then
/// CompareExchange them back into shared memory.
/// </remarks>
internal static void CopyMethodCustomModifiers(
MethodSymbol sourceMethod,
MethodSymbol destinationMethod,
out TypeSymbol returnType,
out ImmutableArray<CustomModifier> returnTypeCustomModifiers,
out ushort countOfCustomModifiersPrecedingByRef,
out ImmutableArray<ParameterSymbol> parameters,
bool alsoCopyParamsModifier) // Last since always named.
{
Debug.Assert((object)sourceMethod != null);
// Assert: none of the method's type parameters have been substituted
Debug.Assert((object)sourceMethod == sourceMethod.ConstructedFrom);
// For the most part, we will copy custom modifiers by copying types.
// The only time when this fails is when the type refers to a type parameter
// owned by the overridden method. We need to replace all such references
// with (equivalent) type parameters owned by this method. We know that
// we can perform this mapping positionally, because the method signatures
// have already been compared.
MethodSymbol constructedSourceMethod = sourceMethod.ConstructIfGeneric(destinationMethod.TypeArguments);
returnTypeCustomModifiers = constructedSourceMethod.ReturnTypeCustomModifiers;
countOfCustomModifiersPrecedingByRef = destinationMethod.ReturnsByRef ? constructedSourceMethod.CountOfCustomModifiersPrecedingByRef : (ushort)0;
parameters = CopyParameterCustomModifiers(constructedSourceMethod.Parameters, destinationMethod.Parameters, alsoCopyParamsModifier);
returnType = destinationMethod.ReturnType; // Default value - in case we don't copy the custom modifiers.
// We do an extra check before copying the return type to handle the case where the overriding
// method (incorrectly) has a different return type than the overridden method. In such cases,
// we want to retain the original (incorrect) return type to avoid hiding the return type
// given in source.
TypeSymbol returnTypeWithCustomModifiers = constructedSourceMethod.ReturnType;
if (returnType.Equals(returnTypeWithCustomModifiers, TypeCompareKind.AllIgnoreOptions))
{
returnType = CopyTypeCustomModifiers(returnTypeWithCustomModifiers, returnType, destinationMethod.ContainingAssembly);
}
}
示例5: CheckExtensionMethod
private void CheckExtensionMethod(
MethodSymbol method,
ImmutableArray<TypeSymbol> typeArgs,
string reducedMethodDescription,
string reducedFromDescription,
string constructedFromDescription,
string reducedAndConstructedFromDescription)
{
// Create instance form from constructed method.
var extensionMethod = ReducedExtensionMethodSymbol.Create(method.ConstructIfGeneric(typeArgs));
Utils.CheckReducedExtensionMethod(extensionMethod, reducedMethodDescription, reducedFromDescription, constructedFromDescription, reducedAndConstructedFromDescription);
// Construct method from unconstructed instance form.
extensionMethod = ReducedExtensionMethodSymbol.Create(method).ConstructIfGeneric(typeArgs);
Utils.CheckReducedExtensionMethod(extensionMethod, reducedMethodDescription, reducedFromDescription, constructedFromDescription, reducedAndConstructedFromDescription);
}