void DefineConstant(ConstantDebugInformation constant) { var row = metadata.AddStandAloneSignature(metadata.GetConstantTypeBlobIndex(constant.ConstantType)); var token = new MetadataToken(TokenType.Signature, row); writer.DefineConstant2(constant.Name, constant.Value, token.ToInt32()); }
private ScopeDebugInformation Clone(ScopeDebugInformation scope, MethodDefinition context) { var scopeDebugInfo = new ScopeDebugInformation( context.Body.Instructions.First(i => i.Offset == scope.Start.Offset), scope.End.IsEndOfMethod ? null : context.Body.Instructions.First(i => i.Offset == scope.End.Offset)); if (scope.HasCustomDebugInformations) { scopeDebugInfo.CustomDebugInformations.AddRange(scope.CustomDebugInformations); } if (scope.HasScopes) { foreach (var innerScope in scope.Scopes) { scopeDebugInfo.Scopes.Add(Clone(innerScope, context)); } } if (scope.Import != null) { scopeDebugInfo.Import = Clone(scope.Import, context); } if (scope.HasVariables) { scopeDebugInfo.Variables.AddRange(scope.Variables); } if (scope.HasConstants) { foreach (var constantDebugInformation in scope.Constants) { var di = new ConstantDebugInformation(constantDebugInformation.Name, Import(constantDebugInformation.ConstantType, context), constantDebugInformation.Value); if (constantDebugInformation.HasCustomDebugInformations) { di.CustomDebugInformations.AddRange(constantDebugInformation.CustomDebugInformations); } scopeDebugInfo.Constants.Add(di); } } return(scopeDebugInfo); }