Exemple #1
0
        public static async Task TestSymbolTreeInfoSerialization()
        {
            var solution    = GetSolution(WorkspaceKind.SingleClass);
            var compilation = await solution.Projects.First().GetCompilationAsync();

            var assembly = compilation.GetSpecialType(SpecialType.System_Byte).ContainingAssembly;
            ////var assembly = compilation.Assembly;

            // create symbol tree info from assembly
            var version = VersionStamp.Create();
            var info    = SymbolTreeInfo.CreateSymbolTreeInfo(
                solution, version, assembly, "", includeInternal: true, cancellationToken: CancellationToken.None);

            using (var writerStream = new MemoryStream())
            {
                using (var writer = new ObjectWriter(writerStream))
                {
                    info.WriteTo(writer);
                }

                using (var readerStream = new MemoryStream(writerStream.ToArray()))
                    using (var reader = new ObjectReader(readerStream))
                    {
                        var readInfo = SymbolTreeInfo.ReadSymbolTreeInfo_ForTestingPurposesOnly(reader);

                        Assert.True(info.IsEquivalent(readInfo));
                    }
            }
        }