本文整理汇总了C#中Internal.TypeSystem.DefType.GetDiagnosticFields方法的典型用法代码示例。如果您正苦于以下问题:C# DefType.GetDiagnosticFields方法的具体用法?C# DefType.GetDiagnosticFields怎么用?C# DefType.GetDiagnosticFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Internal.TypeSystem.DefType
的用法示例。
在下文中一共展示了DefType.GetDiagnosticFields方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterDebugDataForType
public static void RegisterDebugDataForType(TypeBuilder typeBuilder, DefType defType, TypeBuilderState state)
{
if (!defType.IsGeneric())
{
RegisterDebugDataForNativeFormatType(typeBuilder, defType, state);
return;
}
if (defType.IsGenericDefinition)
{
// We don't yet have an encoding for open generic types
// TODO! fill this in
return;
}
NativePrimitiveEncoder encoder = new NativePrimitiveEncoder();
encoder.Init();
IntPtr gcStaticFieldData = TypeLoaderEnvironment.Instance.TryGetGcStaticFieldData(typeBuilder.GetRuntimeTypeHandle(defType));
IntPtr nonGcStaticFieldData = TypeLoaderEnvironment.Instance.TryGetNonGcStaticFieldData(typeBuilder.GetRuntimeTypeHandle(defType));
bool isUniversalGenericType = state.TemplateType != null && state.TemplateType.IsCanonicalSubtype(CanonicalFormKind.Universal);
bool embeddedTypeSizeAndFieldOffsets = isUniversalGenericType || (state.TemplateType == null);
uint instanceFieldCount = 0;
uint staticFieldCount = 0;
// GetDiagnosticFields only returns the fields that are of interest for diagnostic reporting. So it doesn't
// return a meaningful list for non-universal canonical templates
IEnumerable<FieldDesc> diagnosticFields = defType.GetDiagnosticFields();
foreach (var f in diagnosticFields)
{
if (f.IsLiteral)
continue;
if (f.IsStatic)
{
++staticFieldCount;
}
else
{
++instanceFieldCount;
}
}
SharedTypeFlags sharedTypeFlags = 0;
if (gcStaticFieldData != IntPtr.Zero) sharedTypeFlags |= SharedTypeFlags.HasGCStaticFieldRegion;
if (nonGcStaticFieldData != IntPtr.Zero) sharedTypeFlags |= SharedTypeFlags.HasNonGCStaticFieldRegion;
if (state.ThreadDataSize != 0) sharedTypeFlags |= SharedTypeFlags.HasThreadStaticFieldRegion;
if (embeddedTypeSizeAndFieldOffsets)
{
sharedTypeFlags |= SerializedDebugData.SharedTypeFlags.HasTypeSize;
if (instanceFieldCount > 0)
sharedTypeFlags |= SerializedDebugData.SharedTypeFlags.HasInstanceFields;
if (staticFieldCount > 0)
sharedTypeFlags |= SerializedDebugData.SharedTypeFlags.HasStaticFields;
}
Instance.SerializeDataBlobTypeAndFlags(ref encoder, SerializedDataBlobKind.SharedType, (byte)sharedTypeFlags);
//
// The order of these writes is a contract shared between the runtime and debugger engine.
// Changes here must also be updated in the debugger reader code
//
encoder.WriteUnsignedLong((ulong)typeBuilder.GetRuntimeTypeHandle(defType).ToIntPtr().ToInt64());
encoder.WriteUnsigned((uint)defType.Instantiation.Length);
foreach (var instParam in defType.Instantiation)
{
encoder.WriteUnsignedLong((ulong)typeBuilder.GetRuntimeTypeHandle(instParam).ToIntPtr().ToInt64());
}
if (gcStaticFieldData != IntPtr.Zero)
{
encoder.WriteUnsignedLong((ulong)gcStaticFieldData.ToInt64());
}
if (nonGcStaticFieldData != IntPtr.Zero)
{
encoder.WriteUnsignedLong((ulong)nonGcStaticFieldData.ToInt64());
}
// Write the TLS offset into the native thread's TLS buffer. That index de-referenced is the thread static
// data region for this type
if (state.ThreadDataSize != 0)
{
encoder.WriteUnsigned(state.ThreadStaticOffset);
}
// Collect information debugger only requires for universal generics and dynamically loaded types
if (embeddedTypeSizeAndFieldOffsets)
{
Debug.Assert(state.TypeSize != null);
encoder.WriteUnsigned((uint)state.TypeSize);
if (instanceFieldCount > 0)
{
encoder.WriteUnsigned(instanceFieldCount);
//.........这里部分代码省略.........