Ejemplo n.º 1
0
        public static void TestSymbolTreeInfoSerialization()
        {
            var solution    = GetSolution(WorkspaceKind.SingleClass);
            var compilation = solution.Projects.First().GetCompilationAsync().Result;
            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.Create(version, assembly, 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.ReadFrom(reader);

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