本文整理汇总了C#中EntityHandle类的典型用法代码示例。如果您正苦于以下问题:C# EntityHandle类的具体用法?C# EntityHandle怎么用?C# EntityHandle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityHandle类属于命名空间,在下文中一共展示了EntityHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsValidCatchTypeHandle
internal static bool IsValidCatchTypeHandle(EntityHandle catchType)
{
return !catchType.IsNil &&
(catchType.Kind == HandleKind.TypeDefinition ||
catchType.Kind == HandleKind.TypeSpecification ||
catchType.Kind == HandleKind.TypeReference);
}
示例2: CilExceptionRegion
internal CilExceptionRegion(HandlerKind kind, EntityHandle catchType, int startOffset, int filterHandlerStart, int endOffset)
{
Kind = kind;
CatchType = catchType;
StartOffset = startOffset;
FilterHandlerStart = filterHandlerStart;
EndOffset = endOffset;
}
示例3: InitializeObsoleteDataFromMetadata
/// <summary>
/// Initialize the ObsoleteAttributeData by fetching attributes and decoding ObsoleteAttributeData. This can be
/// done for Metadata symbol easily whereas trying to do this for source symbols could result in cycles.
/// </summary>
internal static void InitializeObsoleteDataFromMetadata(ref ObsoleteAttributeData data, EntityHandle token, PEModuleSymbol containingModule)
{
if (ReferenceEquals(data, ObsoleteAttributeData.Uninitialized))
{
ObsoleteAttributeData obsoleteAttributeData = GetObsoleteDataFromMetadata(token, containingModule);
Interlocked.CompareExchange(ref data, obsoleteAttributeData, ObsoleteAttributeData.Uninitialized);
}
}
示例4: GetObsoleteDataFromMetadata
/// <summary>
/// Get the ObsoleteAttributeData by fetching attributes and decoding ObsoleteAttributeData. This can be
/// done for Metadata symbol easily whereas trying to do this for source symbols could result in cycles.
/// </summary>
internal static ObsoleteAttributeData GetObsoleteDataFromMetadata(EntityHandle token, PEModuleSymbol containingModule)
{
ObsoleteAttributeData obsoleteAttributeData;
bool isObsolete = containingModule.Module.HasDeprecatedOrObsoleteAttribute(token, out obsoleteAttributeData);
Debug.Assert(isObsolete == (obsoleteAttributeData != null));
Debug.Assert(obsoleteAttributeData == null || !obsoleteAttributeData.IsUninitialized);
return obsoleteAttributeData;
}
示例5: GetRowNumber
/// <summary>
/// Returns the row number of a metadata table entry that corresponds
/// to the specified <paramref name="handle"/> in the context of <paramref name="reader"/>.
/// </summary>
/// <returns>One based row number.</returns>
/// <exception cref="ArgumentException">The <paramref name="handle"/> is not a valid metadata table handle.</exception>
public static int GetRowNumber(this MetadataReader reader, EntityHandle handle)
{
if (handle.IsVirtual)
{
return MapVirtualHandleRowId(reader, handle);
}
return handle.RowId;
}
示例6: GetToken
/// <summary>
/// Returns the metadata token of the specified <paramref name="handle"/> in the context of <paramref name="reader"/>.
/// </summary>
/// <returns>Metadata token.</returns>
/// <exception cref="NotSupportedException">The operation is not supported for the specified <paramref name="handle"/>.</exception>
public static int GetToken(this MetadataReader reader, EntityHandle handle)
{
if (handle.IsVirtual)
{
return (int)handle.Type | MapVirtualHandleRowId(reader, handle);
}
return handle.Token;
}
示例7: ConvertToTag
internal static uint ConvertToTag(EntityHandle handle)
{
if (handle.Type == TokenTypeIds.FieldDef)
{
return (uint)handle.RowId << NumberOfBits | Field;
}
else if (handle.Type == TokenTypeIds.ParamDef)
{
return (uint)handle.RowId << NumberOfBits | Param;
}
return 0;
}
示例8: GetCustomDebugInformation
internal static BlobHandle GetCustomDebugInformation(this MetadataReader reader, EntityHandle parent, Guid kind)
{
foreach (var cdiHandle in reader.GetCustomDebugInformation(parent))
{
var cdi = reader.GetCustomDebugInformation(cdiHandle);
if (reader.GetGuid(cdi.Kind) == kind)
{
// return the first record
return cdi.Value;
}
}
return default(BlobHandle);
}
示例9: ExceptionHandlerInfo
public ExceptionHandlerInfo(
ExceptionRegionKind kind,
LabelHandle tryStart,
LabelHandle tryEnd,
LabelHandle handlerStart,
LabelHandle handlerEnd,
LabelHandle filterStart,
EntityHandle catchType)
{
Kind = kind;
TryStart = tryStart;
TryEnd = tryEnd;
HandlerStart = handlerStart;
HandlerEnd = handlerEnd;
FilterStart = filterStart;
CatchType = catchType;
}
示例10: ConvertToTag
internal static uint ConvertToTag(EntityHandle handle)
{
uint tokenType = handle.Type;
uint rowId = (uint)handle.RowId;
switch (tokenType >> TokenTypeIds.RowIdBitCount)
{
case TokenTypeIds.TypeDef >> TokenTypeIds.RowIdBitCount:
return rowId << NumberOfBits | TypeDef;
case TokenTypeIds.MethodDef >> TokenTypeIds.RowIdBitCount:
return rowId << NumberOfBits | MethodDef;
case TokenTypeIds.Assembly >> TokenTypeIds.RowIdBitCount:
return rowId << NumberOfBits | Assembly;
}
return 0;
}
示例11: DecodeTupleTypesIfApplicable
public static TypeSymbol DecodeTupleTypesIfApplicable(
TypeSymbol metadataType,
EntityHandle targetSymbolToken,
PEModuleSymbol containingModule)
{
ImmutableArray<string> elementNames;
var hasTupleElementNamesAttribute = containingModule
.Module
.HasTupleElementNamesAttribute(targetSymbolToken, out elementNames);
// If we have the TupleElementNamesAttribute, but no names, that's
// bad metadata
if (hasTupleElementNamesAttribute && elementNames.IsDefaultOrEmpty)
{
return new UnsupportedMetadataTypeSymbol();
}
return DecodeTupleTypesInternal(metadataType, containingModule.ContainingAssembly, elementNames, hasTupleElementNamesAttribute);
}
示例12: ConvertToTag
internal static uint ConvertToTag(EntityHandle token)
{
HandleKind tokenKind = token.Kind;
uint rowId = (uint)token.RowId;
if (tokenKind == HandleKind.FieldDefinition)
{
return rowId << NumberOfBits | Field;
}
else if (tokenKind == HandleKind.Parameter)
{
return rowId << NumberOfBits | Param;
}
else if (tokenKind == HandleKind.PropertyDefinition)
{
return rowId << NumberOfBits | Property;
}
return 0;
}
示例13: GetTypeDefOrRefOrSpecCodedIndex
internal static int GetTypeDefOrRefOrSpecCodedIndex(EntityHandle typeHandle)
{
int tag = 0;
switch (typeHandle.Kind)
{
case HandleKind.TypeDefinition:
tag = 0;
break;
case HandleKind.TypeReference:
tag = 1;
break;
case HandleKind.TypeSpecification:
tag = 2;
break;
}
return (MetadataTokens.GetRowNumber(typeHandle) << 2) | tag;
}
示例14: DecodeTupleTypesIfApplicable
public static TypeSymbol DecodeTupleTypesIfApplicable(
TypeSymbol metadataType,
EntityHandle targetSymbolToken,
PEModuleSymbol containingModule)
{
Debug.Assert((object)metadataType != null);
Debug.Assert((object)containingModule != null);
ImmutableArray<string> elementNames;
var hasTupleElementNamesAttribute = containingModule
.Module
.HasTupleElementNamesAttribute(targetSymbolToken, out elementNames);
// If we have the TupleElementNamesAttribute, but no names, that's
// bad metadata
if (hasTupleElementNamesAttribute && elementNames.IsDefaultOrEmpty)
{
return new UnsupportedMetadataTypeSymbol();
}
var decoder = new TupleTypeDecoder(elementNames,
containingModule.ContainingAssembly);
try
{
var decoded = decoder.DecodeType(metadataType);
// If not all of the names have been used, the metadata is bad
if (!hasTupleElementNamesAttribute ||
decoder._namesIndex == 0)
{
return decoded;
}
}
catch (InvalidOperationException)
{
// Indicates that the tuple info in the attribute didn't match
// the type. Bad metadata.
}
// Bad metadata
return new UnsupportedMetadataTypeSymbol();
}
示例15: TransformType
/// <summary>
/// Decodes the attributes applied to the given <see paramref="targetSymbol"/> from metadata and checks if <see cref="System.Runtime.CompilerServices.DynamicAttribute"/> is applied.
/// If so, it transforms the given <see paramref="metadataType"/>, using the decoded dynamic transforms attribute argument,
/// by replacing each occurrence of <see cref="System.Object"/> type with dynamic type.
/// If no <see cref="System.Runtime.CompilerServices.DynamicAttribute"/> is applied or the decoded dynamic transforms attribute argument is erroneous,
/// returns the unchanged <see paramref="metadataType"/>.
/// </summary>
/// <remarks>This method is a port of TypeManager::ImportDynamicTransformType from the native compiler.</remarks>
internal static TypeSymbol TransformType(
TypeSymbol metadataType,
int targetSymbolCustomModifierCount,
EntityHandle targetSymbolToken,
PEModuleSymbol containingModule,
RefKind targetSymbolRefKind = RefKind.None)
{
Debug.Assert((object)metadataType != null);
ImmutableArray<bool> dynamicTransformFlags;
if (containingModule.Module.HasDynamicAttribute(targetSymbolToken, out dynamicTransformFlags))
{
return TransformTypeInternal(metadataType, containingModule.ContainingAssembly,
targetSymbolCustomModifierCount, targetSymbolRefKind, dynamicTransformFlags,
haveCustomModifierFlags: true,
checkLength: true);
}
// No DynamicAttribute applied to the target symbol, return unchanged metadataType.
return metadataType;
}