本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Symbols.TypeParameterSymbol类的典型用法代码示例。如果您正苦于以下问题:C# TypeParameterSymbol类的具体用法?C# TypeParameterSymbol怎么用?C# TypeParameterSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeParameterSymbol类属于Microsoft.CodeAnalysis.CSharp.Symbols命名空间,在下文中一共展示了TypeParameterSymbol类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RetargetingTypeParameterSymbol
public RetargetingTypeParameterSymbol(RetargetingModuleSymbol retargetingModule, TypeParameterSymbol underlyingTypeParameter)
: base(underlyingTypeParameter)
{
Debug.Assert((object)retargetingModule != null);
Debug.Assert(!(underlyingTypeParameter is RetargetingTypeParameterSymbol));
_retargetingModule = retargetingModule;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:RetargetingTypeParameterSymbol.cs
示例2: DependsOn
public static bool DependsOn(this TypeParameterSymbol typeParameter1, TypeParameterSymbol typeParameter2)
{
Debug.Assert((object)typeParameter1 != null);
Debug.Assert((object)typeParameter2 != null);
Func<TypeParameterSymbol, IEnumerable<TypeParameterSymbol>> dependencies = x => x.ConstraintTypesNoUseSiteDiagnostics.OfType<TypeParameterSymbol>();
return dependencies.TransitiveClosure(typeParameter1).Contains(typeParameter2);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:8,代码来源:TypeParameterSymbolExtensions.cs
示例3: SubstitutedTypeParameterSymbol
internal SubstitutedTypeParameterSymbol(Symbol newContainer, TypeMap map, TypeParameterSymbol substitutedFrom)
{
_container = newContainer;
// it is important that we don't use the map here in the constructor, as the map is still being filled
// in by TypeMap.WithAlphaRename. Instead, we can use the map lazily when yielding the constraints.
_map = map;
_substitutedFrom = substitutedFrom;
}
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:8,代码来源:SubstitutedTypeParameterSymbol.cs
示例4: RetargetingTypeParameterSymbol
public RetargetingTypeParameterSymbol(RetargetingModuleSymbol retargetingModule, TypeParameterSymbol underlyingTypeParameter)
{
Debug.Assert((object)retargetingModule != null);
Debug.Assert((object)underlyingTypeParameter != null);
Debug.Assert(!(underlyingTypeParameter is RetargetingTypeParameterSymbol));
this.retargetingModule = retargetingModule;
this.underlyingTypeParameter = underlyingTypeParameter;
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:9,代码来源:RetargetingTypeParameterSymbol.cs
示例5: SubstituteTypeParameter
protected sealed override TypeSymbol SubstituteTypeParameter(TypeParameterSymbol typeParameter)
{
// It might need to be substituted directly.
TypeSymbol result;
if (Mapping.TryGetValue(typeParameter, out result))
{
return result;
}
return typeParameter;
}
开发者ID:GloryChou,项目名称:roslyn,代码行数:11,代码来源:AbstractTypeParameterMap.cs
示例6: SubstituteTypeParameter
protected sealed override TypeWithModifiers SubstituteTypeParameter(TypeParameterSymbol typeParameter)
{
// It might need to be substituted directly.
TypeWithModifiers result;
if (Mapping.TryGetValue(typeParameter, out result))
{
return result;
}
return new TypeWithModifiers(typeParameter);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:11,代码来源:AbstractTypeParameterMap.cs
示例7: EETypeParameterSymbol
public EETypeParameterSymbol(
Symbol container,
TypeParameterSymbol sourceTypeParameter,
int ordinal,
Func<TypeMap> getTypeMap)
{
Debug.Assert((container.Kind == SymbolKind.NamedType) || (container.Kind == SymbolKind.Method));
_container = container;
_sourceTypeParameter = sourceTypeParameter;
_ordinal = ordinal;
_getTypeMap = getTypeMap;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:12,代码来源:EETypeParameterSymbol.cs
示例8: SubstitutedTypeParameterSymbol
internal SubstitutedTypeParameterSymbol(Symbol newContainer, TypeMap map, TypeParameterSymbol substitutedFrom, int ordinal)
{
_container = newContainer;
// it is important that we don't use the map here in the constructor, as the map is still being filled
// in by TypeMap.WithAlphaRename. Instead, we can use the map lazily when yielding the constraints.
_map = map;
_substitutedFrom = substitutedFrom;
_ordinal = ordinal;
#if DEBUG_ALPHA
_mySequence = _nextSequence++;
#endif
}
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:12,代码来源:SubstitutedTypeParameterSymbol.cs
示例9: SubstituteTypeParameter
protected sealed override TypeWithModifiers SubstituteTypeParameter(TypeParameterSymbol typeParameter)
{
// It might need to be substituted directly.
TypeWithModifiers result;
if (Mapping.TryGetValue(typeParameter, out result))
{
if (typeParameter.NullabilityPreservation == CodeAnalysis.Symbols.NullabilityPreservationKind.None && result.Type.Kind == SymbolKind.NonNullableReference)
{
return new TypeWithModifiers(((NonNullableReferenceTypeSymbol)result.Type).UnderlyingType);
}
return result;
}
return new TypeWithModifiers(typeParameter);
}
开发者ID:jeffanders,项目名称:roslyn,代码行数:15,代码来源:AbstractTypeParameterMap.cs
示例10: SynthesizedContainer
/// <summary>
/// Used for <see cref="SynthesizedDelegateSymbol"/> construction.
/// </summary>
protected SynthesizedContainer(NamespaceOrTypeSymbol containingSymbol, string name, int parameterCount, bool returnsVoid)
{
var typeParameters = new TypeParameterSymbol[parameterCount + (returnsVoid ? 0 : 1)];
for (int i = 0; i < parameterCount; i++)
{
typeParameters[i] = new AnonymousTypeManager.AnonymousTypeParameterSymbol(this, i, "T" + (i + 1));
}
if (!returnsVoid)
{
typeParameters[parameterCount] = new AnonymousTypeManager.AnonymousTypeParameterSymbol(this, parameterCount, "TResult");
}
this.containingSymbol = containingSymbol;
this.name = name;
this.TypeMap = TypeMap.Empty;
this.typeParameters = typeParameters.AsImmutableOrNull();
}
开发者ID:riversky,项目名称:roslyn,代码行数:21,代码来源:SynthesizedContainer.cs
示例11: GrowPool
private static void GrowPool(int count)
{
var initialPool = s_parameterPool;
while (count > initialPool.Length)
{
var newPoolSize = ((count + 0x0F) & ~0xF); // grow in increments of 16
var newPool = new TypeParameterSymbol[newPoolSize];
Array.Copy(initialPool, newPool, initialPool.Length);
for (int i = initialPool.Length; i < newPool.Length; i++)
{
newPool[i] = new IndexedTypeParameterSymbol(i);
}
Interlocked.CompareExchange(ref s_parameterPool, newPool, initialPool);
// repeat if race condition occurred and someone else resized the pool before us
// and the new pool is still too small
initialPool = s_parameterPool;
}
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:22,代码来源:IndexedTypeParameterSymbol.cs
示例12: Contains
/// <summary>
/// Return true if the given type contains the specified type parameter.
/// </summary>
private static bool Contains(TypeSymbol type, TypeParameterSymbol typeParam)
{
switch (type.Kind)
{
case SymbolKind.ArrayType:
return Contains(((ArrayTypeSymbol)type).ElementType, typeParam);
case SymbolKind.PointerType:
return Contains(((PointerTypeSymbol)type).PointedAtType, typeParam);
case SymbolKind.NamedType:
case SymbolKind.ErrorType:
{
NamedTypeSymbol namedType = (NamedTypeSymbol)type;
while ((object)namedType != null)
{
ImmutableArray<TypeSymbol> typeParts = namedType.IsTupleType ? namedType.TupleElementTypes : namedType.TypeArgumentsNoUseSiteDiagnostics;
foreach (TypeSymbol typePart in typeParts)
{
if (Contains(typePart, typeParam))
{
return true;
}
}
namedType = namedType.ContainingType;
}
return false;
}
case SymbolKind.TypeParameter:
return type == typeParam;
default:
return false;
}
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:36,代码来源:TypeUnification.cs
示例13: AddSubstitution
private static void AddSubstitution(ref MutableTypeMap substitution, TypeParameterSymbol tp1, TypeWithModifiers t2)
{
if (substitution == null)
{
substitution = new MutableTypeMap();
}
// MutableTypeMap.Add will throw if the key has already been added. However,
// if t1 was already in the substitution, it would have been substituted at the
// start of CanUnifyHelper and we wouldn't be here.
substitution.Add(tp1, t2);
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:12,代码来源:TypeUnification.cs
示例14: GenerateConflictingConstraintsError
private static TypeParameterDiagnosticInfo GenerateConflictingConstraintsError(TypeParameterSymbol typeParameter, TypeSymbol deducedBase, bool classConflict)
{
// "Type parameter '{0}' inherits conflicting constraints '{1}' and '{2}'"
return new TypeParameterDiagnosticInfo(typeParameter, new CSDiagnosticInfo(ErrorCode.ERR_BaseConstraintConflict, typeParameter, deducedBase, classConflict ? "class" : "struct"));
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:5,代码来源:ConstraintsHelper.cs
示例15: IsValueType
private static bool IsValueType(TypeParameterSymbol typeParameter, ImmutableArray<TypeSymbol> constraintTypes)
{
return typeParameter.HasValueTypeConstraint || TypeParameterSymbol.IsValueTypeFromConstraintTypes(constraintTypes);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:4,代码来源:ConstraintsHelper.cs
示例16: AppendUseSiteDiagnostics
private static bool AppendUseSiteDiagnostics(
HashSet<DiagnosticInfo> useSiteDiagnostics,
TypeParameterSymbol typeParameter,
ref ArrayBuilder<TypeParameterDiagnosticInfo> useSiteDiagnosticsBuilder)
{
if (useSiteDiagnostics.IsNullOrEmpty())
{
return false;
}
if (useSiteDiagnosticsBuilder == null)
{
useSiteDiagnosticsBuilder = new ArrayBuilder<TypeParameterDiagnosticInfo>();
}
bool hasErrors = false;
foreach (var info in useSiteDiagnostics)
{
if (info.Severity == DiagnosticSeverity.Error)
{
hasErrors = true;
}
useSiteDiagnosticsBuilder.Add(new TypeParameterDiagnosticInfo(typeParameter, info));
}
return hasErrors;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:29,代码来源:ConstraintsHelper.cs
示例17: DoesOutputTypeContain
////////////////////////////////////////////////////////////////////////////////
//
// Output types
//
private static bool DoesOutputTypeContain(BoundExpression argument, TypeSymbol formalParameterType,
TypeParameterSymbol typeParameter)
{
// SPEC: If E is a method group or an anonymous function and T is a delegate
// SPEC: type or expression tree type then the return type of T is an output type
// SPEC: of E with type T.
var delegateType = formalParameterType.GetDelegateType();
if ((object)delegateType == null)
{
return false;
}
if (argument.Kind != BoundKind.UnboundLambda && argument.Kind != BoundKind.MethodGroup)
{
return false;
}
MethodSymbol delegateInvoke = delegateType.DelegateInvokeMethod;
if ((object)delegateInvoke == null || delegateInvoke.HasUseSiteError)
{
return false;
}
var delegateReturnType = delegateInvoke.ReturnType;
if ((object)delegateReturnType == null)
{
return false;
}
return delegateReturnType.ContainsTypeParameter(typeParameter);
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:36,代码来源:MethodTypeInference.cs
示例18: AnonymousTypeTemplateSymbol
internal AnonymousTypeTemplateSymbol(AnonymousTypeManager manager, AnonymousTypeDescriptor typeDescr)
{
this.Manager = manager;
this.TypeDescriptorKey = typeDescr.Key;
_smallestLocation = typeDescr.Location;
// Will be set when the type's metadata is ready to be emitted,
// <anonymous-type>.Name will throw exception if requested
// before that moment.
_nameAndIndex = null;
int fieldsCount = typeDescr.Fields.Length;
// members
Symbol[] members = new Symbol[fieldsCount * 3 + 1];
int memberIndex = 0;
// The array storing property symbols to be used in
// generation of constructor and other methods
if (fieldsCount > 0)
{
AnonymousTypePropertySymbol[] propertiesArray = new AnonymousTypePropertySymbol[fieldsCount];
TypeParameterSymbol[] typeParametersArray = new TypeParameterSymbol[fieldsCount];
// Process fields
for (int fieldIndex = 0; fieldIndex < fieldsCount; fieldIndex++)
{
AnonymousTypeField field = typeDescr.Fields[fieldIndex];
// Add a type parameter
AnonymousTypeParameterSymbol typeParameter =
new AnonymousTypeParameterSymbol(this, fieldIndex, GeneratedNames.MakeAnonymousTypeParameterName(field.Name));
typeParametersArray[fieldIndex] = typeParameter;
// Add a property
AnonymousTypePropertySymbol property = new AnonymousTypePropertySymbol(this, field, typeParameter);
propertiesArray[fieldIndex] = property;
// Property related symbols
members[memberIndex++] = property;
members[memberIndex++] = property.BackingField;
members[memberIndex++] = property.GetMethod;
}
_typeParameters = typeParametersArray.AsImmutable();
this.Properties = propertiesArray.AsImmutable();
}
else
{
_typeParameters = ImmutableArray<TypeParameterSymbol>.Empty;
this.Properties = ImmutableArray<AnonymousTypePropertySymbol>.Empty;
}
// Add a constructor
members[memberIndex++] = new AnonymousTypeConstructorSymbol(this, this.Properties);
_members = members.AsImmutable();
Debug.Assert(memberIndex == _members.Length);
// fill nameToSymbols map
foreach (var symbol in _members)
{
_nameToSymbols.Add(symbol.Name, symbol);
}
// special members: Equals, GetHashCode, ToString
MethodSymbol[] specialMembers = new MethodSymbol[3];
specialMembers[0] = new AnonymousTypeEqualsMethodSymbol(this);
specialMembers[1] = new AnonymousTypeGetHashCodeMethodSymbol(this);
specialMembers[2] = new AnonymousTypeToStringMethodSymbol(this);
this.SpecialMembers = specialMembers.AsImmutable();
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:72,代码来源:AnonymousType.TemplateSymbol.cs
示例19: TypeParameterDiagnosticInfo
public TypeParameterDiagnosticInfo(TypeParameterSymbol typeParameter, DiagnosticInfo diagnosticInfo)
{
this.TypeParameter = typeParameter;
this.DiagnosticInfo = diagnosticInfo;
}
开发者ID:XieShuquan,项目名称:roslyn,代码行数:5,代码来源:ConstraintsHelper.cs
示例20: GetTypeInferredDuringReduction
public override TypeSymbol GetTypeInferredDuringReduction(TypeParameterSymbol reducedFromTypeParameter)
{
// This will throw if API shouldn't be supported or there is a problem with the argument.
var notUsed = originalDefinition.GetTypeInferredDuringReduction(reducedFromTypeParameter);
Debug.Assert((object)notUsed == null && (object)originalDefinition.ReducedFrom != null);
return this.TypeArguments[reducedFromTypeParameter.Ordinal];
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:8,代码来源:SubstitutedMethodSymbol.cs
注:本文中的Microsoft.CodeAnalysis.CSharp.Symbols.TypeParameterSymbol类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论