本文整理汇总了C#中IMethodBody.GetSequencePoints方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodBody.GetSequencePoints方法的具体用法?C# IMethodBody.GetSequencePoints怎么用?C# IMethodBody.GetSequencePoints使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodBody
的用法示例。
在下文中一共展示了IMethodBody.GetSequencePoints方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializeDebugInfo
public void SerializeDebugInfo(IMethodBody methodBody, uint localSignatureToken, CustomDebugInfoWriter customDebugInfoWriter)
{
Debug.Assert(_metadataWriter != null);
bool isIterator = methodBody.StateMachineTypeName != null;
bool emitDebugInfo = isIterator || methodBody.HasAnySequencePoints;
if (!emitDebugInfo)
{
return;
}
int methodToken = _metadataWriter.GetMethodToken(methodBody.MethodDefinition);
OpenMethod((uint)methodToken, methodBody.MethodDefinition);
var localScopes = methodBody.LocalScopes;
// Define locals, constants and namespaces in the outermost local scope (opened in OpenMethod):
if (localScopes.Length > 0)
{
this.DefineScopeLocals(localScopes[0], localSignatureToken);
}
// NOTE: This is an attempt to match Dev10's apparent behavior. For iterator methods (i.e. the method
// that appears in source, not the synthesized ones), Dev10 only emits the ForwardIterator and IteratorLocal
// custom debug info (e.g. there will be no information about the usings that were in scope).
if (!isIterator && methodBody.ImportScope != null)
{
IMethodDefinition forwardToMethod;
if (customDebugInfoWriter.ShouldForwardNamespaceScopes(Context, methodBody, methodToken, out forwardToMethod))
{
if (forwardToMethod != null)
{
UsingNamespace("@" + _metadataWriter.GetMethodToken(forwardToMethod), methodBody.MethodDefinition);
}
// otherwise, the forwarding is done via custom debug info
}
else
{
this.DefineNamespaceScopes(methodBody);
}
}
DefineLocalScopes(localScopes, localSignatureToken);
EmitSequencePoints(methodBody.GetSequencePoints());
AsyncMethodBodyDebugInfo asyncDebugInfo = methodBody.AsyncDebugInfo;
if (asyncDebugInfo != null)
{
SetAsyncInfo(
methodToken,
_metadataWriter.GetMethodToken(asyncDebugInfo.KickoffMethod),
asyncDebugInfo.CatchHandlerOffset,
asyncDebugInfo.YieldOffsets,
asyncDebugInfo.ResumeOffsets);
}
var compilationOptions = Context.ModuleBuilder.CommonCompilation.Options;
// We need to avoid emitting CDI DynamicLocals = 5 and EditAndContinueLocalSlotMap = 6 for files processed by WinMDExp until
// bug #1067635 is fixed and available in SDK.
bool suppressNewCustomDebugInfo = !compilationOptions.ExtendedCustomDebugInformation ||
(compilationOptions.OutputKind == OutputKind.WindowsRuntimeMetadata);
bool emitEncInfo = compilationOptions.EnableEditAndContinue && !_metadataWriter.IsFullMetadata;
bool emitExternNamespaces;
byte[] blob = customDebugInfoWriter.SerializeMethodDebugInfo(Context, methodBody, methodToken, emitEncInfo, suppressNewCustomDebugInfo, out emitExternNamespaces);
if (blob != null)
{
DefineCustomMetadata("MD2", blob);
}
if (emitExternNamespaces)
{
this.DefineAssemblyReferenceAliases();
}
CloseMethod(methodBody.IL.Length);
}
示例2: SerializeDebugInfo
public void SerializeDebugInfo(IMethodBody methodBody, uint localSignatureToken, CustomDebugInfoWriter customDebugInfoWriter)
{
Debug.Assert(peWriter != null);
bool isIterator = methodBody.IteratorClassName != null;
bool emitDebugInfo = isIterator || methodBody.HasAnyLocations;
if (!emitDebugInfo)
{
return;
}
uint methodToken = peWriter.GetMethodToken(methodBody.MethodDefinition);
OpenMethod(methodToken);
var localScopes = methodBody.LocalScopes;
// CCI originally didn't have the notion of the default scope that is open
// when a method is opened. In order to reproduce CSC PDBs, this must be added. Otherwise
// a seemingly unnecessary scope that contains only other scopes is put in the PDB.
if (localScopes.Length > 0)
{
this.DefineScopeLocals(localScopes[0], localSignatureToken);
}
// NOTE: This is an attempt to match Dev10's apparent behavior. For iterator methods (i.e. the method
// that appears in source, not the synthesized ones), Dev10 only emits the ForwardIterator and IteratorLocal
// custom debug info (e.g. there will be no information about the usings that were in scope).
if (!isIterator)
{
IMethodDefinition forwardToMethod;
if (customDebugInfoWriter.ShouldForwardNamespaceScopes(methodBody, methodToken, out forwardToMethod))
{
if (forwardToMethod != null)
{
string usingString = "@" + peWriter.GetMethodToken(forwardToMethod);
Debug.Assert(!peWriter.IsUsingStringTooLong(usingString));
UsingNamespace(usingString, methodBody.MethodDefinition.Name);
}
// otherwise, the forwarding is done via custom debug info
}
else
{
this.DefineNamespaceScopes(methodBody);
}
}
DefineLocalScopes(localScopes, localSignatureToken);
EmitSequencePoints(methodBody.GetSequencePoints());
AsyncMethodBodyDebugInfo asyncDebugInfo = methodBody.AsyncMethodDebugInfo;
if (asyncDebugInfo != null)
{
SetAsyncInfo(
methodToken,
peWriter.GetMethodToken(asyncDebugInfo.KickoffMethod),
asyncDebugInfo.CatchHandlerOffset,
asyncDebugInfo.YieldOffsets,
asyncDebugInfo.ResumeOffsets);
}
var module = peWriter.Context.Module;
bool emitExternNamespaces;
byte[] blob = customDebugInfoWriter.SerializeMethodDebugInfo(module, methodBody, methodToken, out emitExternNamespaces);
if (blob != null)
{
DefineCustomMetadata("MD2", blob);
}
if (emitExternNamespaces)
{
this.DefineExternAliases(module);
}
// TODO: it's not clear why we are closing a scope here with IL length:
CloseScope((uint)methodBody.IL.Length);
CloseMethod();
}