/// <summary>
            /// Get the unique state name for the given {type, analyzer} tuple.
            /// Note that this name is used by the underlying persistence stream of the corresponding <see cref="DiagnosticState"/> to Read/Write diagnostic data into the stream.
            /// If any two distinct {type, analyzer} tuples have the same diagnostic state name, we will end up sharing the persistence stream between them, leading to duplicate/missing/incorrect diagnostic data.
            /// </summary>
            private static ValueTuple<string, VersionStamp> GetNameAndVersion(DiagnosticAnalyzer analyzer, StateType type)
            {
                Contract.ThrowIfNull(analyzer);

                // Get the unique ID for given diagnostic analyzer.
                // note that we also put version stamp so that we can detect changed analyzer.
                var tuple = analyzer.GetAnalyzerIdAndVersion();
                return ValueTuple.Create(UserDiagnosticsPrefixTableName + "_" + type.ToString() + "_" + tuple.Item1, tuple.Item2);
            }
            /// <summary>
            /// Get the unique state name for the given analyzer.
            /// Note that this name is used by the underlying persistence stream of the corresponding <see cref="ProjectState"/> to Read/Write diagnostic data into the stream.
            /// If any two distinct analyzer have the same diagnostic state name, we will end up sharing the persistence stream between them, leading to duplicate/missing/incorrect diagnostic data.
            /// </summary>
            private static ValueTuple <string, VersionStamp> GetNameAndVersion(DiagnosticAnalyzer analyzer)
            {
                Contract.ThrowIfNull(analyzer);

                // Get the unique ID for given diagnostic analyzer.
                // note that we also put version stamp so that we can detect changed analyzer.
                var tuple = analyzer.GetAnalyzerIdAndVersion();

                return(ValueTuple.Create(UserDiagnosticsPrefixTableName + "_" + tuple.Item1, tuple.Item2));
            }
            public StateSet(string language, DiagnosticAnalyzer analyzer, string errorSourceName)
            {
                Language        = language;
                Analyzer        = analyzer;
                ErrorSourceName = errorSourceName;

                var(_, version) = Analyzer.GetAnalyzerIdAndVersion();
                AnalyzerVersion = version;

                _persistentNames = PersistentNames.Create(Analyzer);

                _activeFileStates = new ConcurrentDictionary <DocumentId, ActiveFileState>(concurrencyLevel: 2, capacity: 10);
                _projectStates    = new ConcurrentDictionary <ProjectId, ProjectState>(concurrencyLevel: 2, capacity: 1);
            }
Exemplo n.º 4
0
            public StateSet(string language, DiagnosticAnalyzer analyzer, string errorSourceName)
            {
                _language        = language;
                _analyzer        = analyzer;
                _errorSourceName = errorSourceName;

                var(analyzerId, version) = _analyzer.GetAnalyzerIdAndVersion();
                _analyzerVersion         = version;
                _analyzerTypeData        = AnalyzerTypeData.ForType(_analyzer.GetType());
                Debug.Assert(_analyzerTypeData.StateName == $"{AnalyzerTypeData.UserDiagnosticsPrefixTableName}_{analyzerId}", "Expected persistence information for analyzer instance to be derived from its type alone.");

                _activeFileStates = new ConcurrentDictionary <DocumentId, ActiveFileState>(concurrencyLevel: 2, capacity: 10);
                _projectStates    = new ConcurrentDictionary <ProjectId, ProjectState>(concurrencyLevel: 2, capacity: 1);
            }
Exemplo n.º 5
0
 public int GetHashCode(DiagnosticAnalyzer obj) => obj.GetAnalyzerIdAndVersion().GetHashCode();