public byte[] SerializeMethodDebugInfo(EmitContext context, IMethodBody methodBody, MethodDefinitionHandle methodHandle, bool emitEncInfo, bool suppressNewCustomDebugInfo, out bool emitExternNamespaces) { emitExternNamespaces = false; // CONSIDER: this may not be the same "first" method as in Dev10, but // it shouldn't matter since all methods will still forward to a method // containing the appropriate information. if (_methodBodyWithModuleInfo == null) { // This module level information could go on every method (and does in // the edit-and-continue case), but - as an optimization - we'll just // put it on the first method we happen to encounter and then put a // reference to the first method's token in every other method (so they // can find the information). if (context.Module.GetAssemblyReferenceAliases(context).Any()) { _methodWithModuleInfo = methodHandle; _methodBodyWithModuleInfo = methodBody; emitExternNamespaces = true; } } var pooledBuilder = PooledBlobBuilder.GetInstance(); var encoder = new CustomDebugInfoEncoder(pooledBuilder); // 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 StateMachineTypeName // custom debug info (e.g. there will be no information about the usings that were in scope). // NOTE: There seems to be an unusual behavior in ISymUnmanagedWriter where, if all the methods in a type are // iterator methods, no custom debug info is emitted for any method. Adding a single non-iterator // method causes the custom debug info to be produced for all methods (including the iterator methods). // Since we are making the same ISymUnmanagedWriter calls as Dev10, we see the same behavior (i.e. this // is not a regression). if (methodBody.StateMachineTypeName != null) { encoder.AddStateMachineTypeName(methodBody.StateMachineTypeName); } else { SerializeNamespaceScopeMetadata(ref encoder, context, methodBody); encoder.AddStateMachineHoistedLocalScopes(methodBody.StateMachineHoistedLocalScopes); } if (!suppressNewCustomDebugInfo) { SerializeDynamicLocalInfo(ref encoder, methodBody); SerializeTupleElementNames(ref encoder, methodBody); if (emitEncInfo) { var encMethodInfo = MetadataWriter.GetEncMethodDebugInfo(methodBody); SerializeCustomDebugInformation(ref encoder, encMethodInfo); } } byte[] result = encoder.ToArray(); pooledBuilder.Free(); return(result); }
public byte[] SerializeMethodDebugInfo(EmitContext context, IMethodBody methodBody, int methodToken, bool isEncDelta, bool suppressNewCustomDebugInfo, out bool emitExternNamespaces) { emitExternNamespaces = false; // CONSIDER: this may not be the same "first" method as in Dev10, but // it shouldn't matter since all methods will still forward to a method // containing the appropriate information. if (_methodBodyWithModuleInfo == null) //UNDONE: || edit-and-continue { // This module level information could go on every method (and does in // the edit-and-continue case), but - as an optimization - we'll just // put it on the first method we happen to encounter and then put a // reference to the first method's token in every other method (so they // can find the information). if (context.Module.GetAssemblyReferenceAliases(context).Any()) { _methodTokenWithModuleInfo = methodToken; _methodBodyWithModuleInfo = methodBody; emitExternNamespaces = true; } } var customDebugInfo = ArrayBuilder <BlobBuilder> .GetInstance(); SerializeIteratorClassMetadata(methodBody, customDebugInfo); // 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). // NOTE: There seems to be an unusual behavior in ISymUnmanagedWriter where, if all the methods in a type are // iterator methods, no custom debug info is emitted for any method. Adding a single non-iterator // method causes the custom debug info to be produced for all methods (including the iterator methods). // Since we are making the same ISymUnmanagedWriter calls as Dev10, we see the same behavior (i.e. this // is not a regression). if (methodBody.StateMachineTypeName == null) { SerializeNamespaceScopeMetadata(context, methodBody, customDebugInfo); SerializeStateMachineLocalScopes(methodBody, customDebugInfo); } if (!suppressNewCustomDebugInfo) { SerializeDynamicLocalInfo(methodBody, customDebugInfo); // delta doesn't need this information - we use information recorded by previous generation emit if (!isEncDelta) { var encMethodInfo = MetadataWriter.GetEncMethodDebugInfo(methodBody); SerializeCustomDebugInformation(encMethodInfo, customDebugInfo); } } byte[] result = SerializeCustomDebugMetadata(customDebugInfo); customDebugInfo.Free(); return(result); }
public byte[] SerializeMethodDebugInfo(EmitContext context, IMethodBody methodBody, MethodDefinitionHandle methodHandle, bool emitEncInfo, bool suppressNewCustomDebugInfo, out bool emitExternNamespaces) { emitExternNamespaces = false; // CONSIDER: this may not be the same "first" method as in Dev10, but // it shouldn't matter since all methods will still forward to a method // containing the appropriate information. if (_methodBodyWithModuleInfo == null) { // This module level information could go on every method (and does in // the edit-and-continue case), but - as an optimization - we'll just // put it on the first method we happen to encounter and then put a // reference to the first method's token in every other method (so they // can find the information). if (context.Module.GetAssemblyReferenceAliases(context).Any()) { _methodWithModuleInfo = methodHandle; _methodBodyWithModuleInfo = methodBody; emitExternNamespaces = true; } } var pooledBuilder = PooledBlobBuilder.GetInstance(); var encoder = new CustomDebugInfoEncoder(pooledBuilder); if (methodBody.StateMachineTypeName != null) { encoder.AddStateMachineTypeName(methodBody.StateMachineTypeName); } else { SerializeNamespaceScopeMetadata(ref encoder, context, methodBody); encoder.AddStateMachineHoistedLocalScopes(methodBody.StateMachineHoistedLocalScopes); } if (!suppressNewCustomDebugInfo) { SerializeDynamicLocalInfo(ref encoder, methodBody); SerializeTupleElementNames(ref encoder, methodBody); if (emitEncInfo) { var encMethodInfo = MetadataWriter.GetEncMethodDebugInfo(methodBody); SerializeCustomDebugInformation(ref encoder, encMethodInfo); } } byte[] result = encoder.ToArray(); pooledBuilder.Free(); return(result); }