Exemplo n.º 1
0
            internal string VisualizeIL(CompilationTestData.MethodData methodData, bool realIL, string sequencePoints = null)
            {
                Dictionary <int, string> markers = null;

                if (sequencePoints != null)
                {
                    var actualPdbXml = PdbToXmlConverter.ToXml(
                        pdbStream: new MemoryStream(EmittedAssemblyPdb.ToArray()),
                        peStream: new MemoryStream(EmittedAssemblyData.ToArray()),
                        options: PdbToXmlOptions.ResolveTokens |
                        PdbToXmlOptions.ThrowOnError |
                        PdbToXmlOptions.ExcludeDocuments |
                        PdbToXmlOptions.ExcludeCustomDebugInformation |
                        PdbToXmlOptions.ExcludeScopes,
                        methodName: sequencePoints);

                    markers = PdbValidation.GetMarkers(actualPdbXml);
                }

                if (!realIL)
                {
                    return(ILBuilderVisualizer.ILBuilderToString(methodData.ILBuilder, markers: markers));
                }

                if (_lazyModuleSymbol == null)
                {
                    _lazyModuleSymbol = GetModuleSymbolForEmittedImage(EmittedAssemblyData, MetadataImportOptions.All);
                }

                return(_lazyModuleSymbol != null?_test.VisualizeRealIL(_lazyModuleSymbol, methodData, markers) : null);
            }
Exemplo n.º 2
0
        private void VerifyPdb(
            IEnumerable <int> methodTokens,
            string expectedPdb,
            DebugInformationFormat format,
            int expectedValueSourceLine,
            string expectedValueSourcePath,
            bool expectedIsXmlLiteral)
        {
            Assert.NotEqual(default(DebugInformationFormat), format);
            Assert.NotEqual(DebugInformationFormat.Embedded, format);

            string actualPdb = PdbToXmlConverter.DeltaPdbToXml(new ImmutableMemoryStream(PdbDelta), methodTokens);

            var(actualXml, expectedXml) = PdbValidation.AdjustToPdbFormat(actualPdb, expectedPdb, actualIsPortable: NextGeneration.InitialBaseline.HasPortablePdb);

            AssertXml.Equal(expectedXml, actualXml, $"Format: {format}{Environment.NewLine}", expectedValueSourcePath, expectedValueSourceLine, expectedIsXmlLiteral);
        }
Exemplo n.º 3
0
        private void VerifyPdb(
            IEnumerable <int> methodTokens,
            XElement expectedPdb,
            DebugInformationFormat format,
            int expectedValueSourceLine,
            string expectedValueSourcePath,
            bool expectedIsXmlLiteral)
        {
            Assert.NotEqual(DebugInformationFormat.Embedded, format);

            var actualXml = XElement.Parse(PdbToXmlConverter.DeltaPdbToXml(new ImmutableMemoryStream(PdbDelta), methodTokens));

            PdbValidation.AdjustToPdbFormat(
                actualPdb: actualXml,
                actualIsPortable: NextGeneration.InitialBaseline.HasPortablePdb,
                expectedPdb: expectedPdb,
                expectedIsPortable: format != DebugInformationFormat.Pdb);

            AssertXml.Equal(expectedPdb, actualXml, expectedValueSourcePath, expectedValueSourceLine, expectedIsXmlLiteral);
        }
Exemplo n.º 4
0
        public void VerifyIL(
            string qualifiedMethodName,
            string expectedIL,
            Func <Cci.ILocalDefinition, ILVisualizer.LocalInfo> mapLocal = null,
            MethodDefinitionHandle methodToken = default(MethodDefinitionHandle),
            [CallerFilePath] string callerPath = null,
            [CallerLineNumber] int callerLine  = 0)
        {
            var ilBuilder = TestData.GetMethodData(qualifiedMethodName).ILBuilder;

            Dictionary <int, string> sequencePointMarkers = null;

            if (!methodToken.IsNil)
            {
                string actualPdb = PdbToXmlConverter.DeltaPdbToXml(new ImmutableMemoryStream(PdbDelta), new[] { MetadataTokens.GetToken(methodToken) });
                sequencePointMarkers = PdbValidation.GetMarkers(actualPdb);
            }

            string actualIL = ILBuilderVisualizer.ILBuilderToString(ilBuilder, mapLocal ?? ToLocalInfo, sequencePointMarkers);

            AssertEx.AssertEqualToleratingWhitespaceDifferences(expectedIL, actualIL, escapeQuotes: true, expectedValueSourcePath: callerPath, expectedValueSourceLine: callerLine);
        }