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));
                    }
            }
        }
Ejemplo n.º 2
0
            public override async Task AnalyzeProjectAsync(Project project, bool semanticsChanged, CancellationToken cancellationToken)
            {
                if (_symbolCountByProjectMap == null || !project.SupportsCompilation || !semanticsChanged)
                {
                    return;
                }

                // we do this just to report total symbol numbers
                var compilation = await project.GetCompilationAsync(cancellationToken).ConfigureAwait(false);

                var info = SymbolTreeInfo.Create(VersionStamp.Default, compilation.Assembly, cancellationToken);

                if (info != null)
                {
                    RecordCount(project.Id, info.Count);
                }
            }