byte[] Write(PdbCustomDebugInfo cdi)
        {
            switch (cdi.Kind)
            {
            case PdbCustomDebugInfoKind.UsingGroups:
            case PdbCustomDebugInfoKind.ForwardMethodInfo:
            case PdbCustomDebugInfoKind.ForwardModuleInfo:
            case PdbCustomDebugInfoKind.StateMachineTypeName:
            case PdbCustomDebugInfoKind.DynamicLocals:
            case PdbCustomDebugInfoKind.TupleElementNames:
            case PdbCustomDebugInfoKind.IteratorMethod:
            case PdbCustomDebugInfoKind.SourceServer:
            default:
                helper.Error("Unreachable code, caller should filter these out");
                return(null);

            case PdbCustomDebugInfoKind.StateMachineHoistedLocalScopes:
                WriteStateMachineHoistedLocalScopes((PdbStateMachineHoistedLocalScopesCustomDebugInfo)cdi);
                break;

            case PdbCustomDebugInfoKind.EditAndContinueLocalSlotMap:
                WriteEditAndContinueLocalSlotMap((PdbEditAndContinueLocalSlotMapCustomDebugInfo)cdi);
                break;

            case PdbCustomDebugInfoKind.EditAndContinueLambdaMap:
                WriteEditAndContinueLambdaMap((PdbEditAndContinueLambdaMapCustomDebugInfo)cdi);
                break;

            case PdbCustomDebugInfoKind.Unknown:
                WriteUnknown((PdbUnknownCustomDebugInfo)cdi);
                break;

            case PdbCustomDebugInfoKind.TupleElementNames_PortablePdb:
                WriteTupleElementNames((PortablePdbTupleElementNamesCustomDebugInfo)cdi);
                break;

            case PdbCustomDebugInfoKind.DefaultNamespace:
                WriteDefaultNamespace((PdbDefaultNamespaceCustomDebugInfo)cdi);
                break;

            case PdbCustomDebugInfoKind.DynamicLocalVariables:
                WriteDynamicLocalVariables((PdbDynamicLocalVariablesCustomDebugInfo)cdi);
                break;

            case PdbCustomDebugInfoKind.EmbeddedSource:
                WriteEmbeddedSource((PdbEmbeddedSourceCustomDebugInfo)cdi);
                break;

            case PdbCustomDebugInfoKind.SourceLink:
                WriteSourceLink((PdbSourceLinkCustomDebugInfo)cdi);
                break;

            case PdbCustomDebugInfoKind.AsyncMethod:
                WriteAsyncMethodSteppingInformation((PdbAsyncMethodCustomDebugInfo)cdi);
                break;
            }
            return(outStream.ToArray());
        }
示例#2
0
        PdbCustomDebugInfo Clone(PdbCustomDebugInfo source)
        {
            var compatible = true;

            switch (Context.TargetModule.PdbState.PdbFileKind)
            {
            case PdbFileKind.WindowsPDB:
                if ((uint)source.Kind > byte.MaxValue)
                {
                    compatible = false;
                }
                break;
            }

            PdbCustomDebugInfo result = null;

            if (compatible)
            {
                switch (source)
                {
                case PdbForwardMethodInfoCustomDebugInfo i:
                    return(null);    // currently not supported by dnlib

                    result = new PdbForwardMethodInfoCustomDebugInfo((IMethodDefOrRef)Importer.Import(i.Method));
                    break;

                case PdbForwardModuleInfoCustomDebugInfo i:
                    return(null);    // currently not supported by dnlib

                    result = new PdbForwardModuleInfoCustomDebugInfo((IMethodDefOrRef)Importer.Import(i.Method));
                    break;

                case PdbStateMachineTypeNameCustomDebugInfo i:
                    return(null);    // currently not supported by dnlib

                    result = new PdbStateMachineTypeNameCustomDebugInfo(Importer.Import(i.Type).ResolveTypeDef());
                    break;

                case PdbTupleElementNamesCustomDebugInfo i1:
                case PortablePdbTupleElementNamesCustomDebugInfo i2:
                case PdbDefaultNamespaceCustomDebugInfo i3:
                case PdbDynamicLocalVariablesCustomDebugInfo i4:
                case PdbEmbeddedSourceCustomDebugInfo i5:
                case PdbSourceLinkCustomDebugInfo i6:
                case PdbSourceServerCustomDebugInfo i7:
                    throw new NotImplementedException();

                default:
                    result = CloneOther(source);
                    break;
                }
            }
            return(Context.Fire(new NetfuserEvent.CloneCustomDebugInfo(Context, source)
            {
                Target = result
            }).Target);
        }
示例#3
0
        protected override PdbCustomDebugInfo CloneOther(PdbCustomDebugInfo source)
        {
            switch (source)
            {
            case PdbAsyncMethodCustomDebugInfo i:
                var n = new PdbAsyncMethodCustomDebugInfo(i.StepInfos.Count)
                {
                    CatchHandlerInstruction = GetInstruction(i.CatchHandlerInstruction),
                    KickoffMethod           = Importer.Import(i.KickoffMethod).ResolveMethodDefThrow()
                };
                for (var j = 0; j < i.StepInfos.Count; j++)
                {
                    n.StepInfos.Add(new PdbAsyncStepInfo(
                                        GetInstruction(i.StepInfos[j].YieldInstruction),
                                        Importer.Import(i.StepInfos[j].BreakpointMethod).ResolveMethodDefThrow(),
                                        GetInstruction(i.StepInfos[j].BreakpointInstruction)
                                        ));
                }
                return(n);

            case PdbStateMachineHoistedLocalScopesCustomDebugInfo i:
                var nls = new PdbStateMachineHoistedLocalScopesCustomDebugInfo(i.Scopes.Count);
                foreach (var si in nls.Scopes)
                {
                    nls.Scopes.Add(new StateMachineHoistedLocalScope(
                                       GetInstruction(si.Start),
                                       GetInstruction(si.End)));
                }
                return(nls);

            case PdbIteratorMethodCustomDebugInfo i:
                var im = new PdbIteratorMethodCustomDebugInfo
                {
                    KickoffMethod = Importer.Import(i.KickoffMethod).ResolveMethodDefThrow()
                };
                return(im);

            case PdbDynamicLocalsCustomDebugInfo i:
                var ndl = new PdbDynamicLocalsCustomDebugInfo(i.Locals.Count);
                foreach (var si in ndl.Locals)
                {
                    ndl.Locals.Add(Clone(si));
                }
                return(ndl);

            case PdbEditAndContinueLocalSlotMapCustomDebugInfo i2:
            case PdbEditAndContinueLambdaMapCustomDebugInfo i3:
                return(source);
            }

            return(null);
        }
示例#4
0
        public static byte[] Write(IPortablePdbCustomDebugInfoWriterHelper helper, SerializerMethodContext methodContext, MetaData systemMetaData, PdbCustomDebugInfo cdi, BinaryWriterContext context)
        {
            var writer = new PortablePdbCustomDebugInfoWriter(helper, methodContext, systemMetaData, context);

            return(writer.Write(cdi));
        }
示例#5
0
 protected virtual PdbCustomDebugInfo CloneOther(PdbCustomDebugInfo source) => null;
示例#6
0
 internal CloneCustomDebugInfo(IContext context, PdbCustomDebugInfo source)
     : base(context)
 {
     Source = source;
 }