Esempio n. 1
0
        public SkippedHostAnalyzersInfo GetSkippedAnalyzersInfo(
            Project project,
            DiagnosticAnalyzerInfoCache infoCache
            )
        {
            var box = _skippedHostAnalyzers.GetOrCreateValue(project.AnalyzerReferences);

            if (box.Value != null && box.Value.TryGetValue(project.Language, out var info))
            {
                return(info);
            }
            lock (box)
            {
                box.Value ??= ImmutableDictionary <string, SkippedHostAnalyzersInfo> .Empty;

                if (!box.Value.TryGetValue(project.Language, out info))
                {
                    info = SkippedHostAnalyzersInfo.Create(
                        this,
                        project.AnalyzerReferences,
                        project.Language,
                        infoCache
                        );
                    box.Value = box.Value.Add(project.Language, info);
                }

                return(info);
            }
        }
        public ISkippedAnalyzersInfo GetOrCreateSkippedAnalyzersInfo(Project project, IEnumerable <AnalyzerReference> hostAnalyzers)
        {
            if (_skippedAnalyzersInfo.TryGetValue(project.AnalyzerReferences, out var skippedAnalyzersInfo))
            {
                return(skippedAnalyzersInfo);
            }

            var createValueCallback = new ConditionalWeakTable <IReadOnlyList <AnalyzerReference>, ISkippedAnalyzersInfo> .CreateValueCallback(
                _ => SkippedHostAnalyzersInfo.Create(project, hostAnalyzers, this));

            return(_skippedAnalyzersInfo.GetValue(project.AnalyzerReferences, createValueCallback));
        }