示例#1
0
 public static void VerifyPdb(
     this Compilation compilation,
     string qualifiedMethodName,
     XElement expectedPdb,
     IEnumerable <EmbeddedText> embeddedTexts        = null,
     IMethodSymbol debugEntryPoint                   = null,
     DebugInformationFormat format                   = 0,
     PdbValidationOptions options                    = PdbValidationOptions.Default,
     [CallerLineNumber] int expectedValueSourceLine  = 0,
     [CallerFilePath] string expectedValueSourcePath = null
     )
 {
     VerifyPdbImpl(
         compilation,
         embeddedTexts,
         debugEntryPoint,
         qualifiedMethodName,
         expectedPdb.ToString(),
         format,
         options,
         expectedValueSourceLine,
         expectedValueSourcePath,
         expectedIsXmlLiteral: true
         );
 }
示例#2
0
 public static void VerifyPdb(
     this Compilation compilation,
     XElement expectedPdb,
     IEnumerable <EmbeddedText> embeddedTexts        = null,
     IMethodSymbol debugEntryPoint                   = null,
     DebugInformationFormat format                   = 0,
     PdbValidationOptions options                    = PdbValidationOptions.Default,
     [CallerLineNumber] int expectedValueSourceLine  = 0,
     [CallerFilePath] string expectedValueSourcePath = null)
 {
     VerifyPdb(compilation, "", expectedPdb, embeddedTexts, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath);
 }
        public static PdbToXmlOptions ToPdbToXmlOptions(this PdbValidationOptions options)
        {
            const PdbValidationOptions mask =
                PdbValidationOptions.ExcludeDocuments |
                PdbValidationOptions.ExcludeMethods |
                PdbValidationOptions.ExcludeSequencePoints |
                PdbValidationOptions.ExcludeScopes |
                PdbValidationOptions.ExcludeNamespaces |
                PdbValidationOptions.ExcludeAsyncInfo |
                PdbValidationOptions.ExcludeCustomDebugInformation;

            return(PdbToXmlOptions.ResolveTokens | PdbToXmlOptions.ThrowOnError | PdbToXmlOptions.IncludeEmbeddedSources | (PdbToXmlOptions)(options & mask));
        }
示例#4
0
 public static CompilationVerifier VerifyPdb(
     this CompilationVerifier verifier,
     string expectedPdb,
     IEnumerable <EmbeddedText> embeddedTexts        = null,
     IMethodSymbol debugEntryPoint                   = null,
     DebugInformationFormat format                   = 0,
     PdbValidationOptions options                    = PdbValidationOptions.Default,
     [CallerLineNumber] int expectedValueSourceLine  = 0,
     [CallerFilePath] string expectedValueSourcePath = null)
 {
     verifier.Compilation.VerifyPdb(expectedPdb, embeddedTexts, debugEntryPoint, format, options, expectedValueSourceLine, expectedValueSourcePath);
     return(verifier);
 }
示例#5
0
        internal static string GetPdbXml(
            Compilation compilation,
            IEnumerable <EmbeddedText> embeddedTexts = null,
            IMethodSymbol debugEntryPoint            = null,
            PdbValidationOptions options             = PdbValidationOptions.Default,
            string qualifiedMethodName = "",
            bool portable = false)
        {
            var peStream  = new MemoryStream();
            var pdbStream = new MemoryStream();

            EmitWithPdb(peStream, pdbStream, compilation, debugEntryPoint, embeddedTexts, portable);

            pdbStream.Position = 0;
            peStream.Position  = 0;
            return(PdbToXmlConverter.ToXml(pdbStream, peStream, options.ToPdbToXmlOptions(), methodName: qualifiedMethodName));
        }
示例#6
0
        private static void VerifyPdbImpl(
            this Compilation compilation,
            IEnumerable <EmbeddedText> embeddedTexts,
            IMethodSymbol debugEntryPoint,
            string qualifiedMethodName,
            string expectedPdb,
            DebugInformationFormat format,
            PdbValidationOptions options,
            int expectedValueSourceLine,
            string expectedValueSourcePath,
            bool expectedIsXmlLiteral)
        {
            Assert.NotEqual(DebugInformationFormat.Embedded, format);

            bool testWindowsPdb  = format == 0 || format == DebugInformationFormat.Pdb;
            bool testPortablePdb = format == 0 || format == DebugInformationFormat.PortablePdb;
            bool testConversion  = (options & PdbValidationOptions.SkipConversionValidation) == 0;
            var  pdbToXmlOptions = options.ToPdbToXmlOptions();

            if (testWindowsPdb)
            {
                Verify(isPortable: false, testOtherFormat: testPortablePdb);
            }

            if (testPortablePdb)
            {
                Verify(isPortable: true, testOtherFormat: testWindowsPdb);
            }

            void Verify(bool isPortable, bool testOtherFormat)
            {
                var peStream  = new MemoryStream();
                var pdbStream = new MemoryStream();

                EmitWithPdb(peStream, pdbStream, compilation, debugEntryPoint, embeddedTexts, isPortable);

                VerifyPdbMatchesExpectedXml(peStream, pdbStream, qualifiedMethodName, pdbToXmlOptions, expectedPdb, expectedValueSourceLine, expectedValueSourcePath, expectedIsXmlLiteral, isPortable);

                if (testConversion && testOtherFormat)
                {
                    VerifyConvertedPdbMatchesExpectedXml(peStream, pdbStream, qualifiedMethodName, expectedPdb, pdbToXmlOptions, expectedIsXmlLiteral, isPortable);
                }
            }
        }