コード例 #1
0
ファイル: SmallDictionary.cs プロジェクト: zsybupt/roslyn
                public Enumerator(SmallDictionary <K, V> dict)
                    : this()
                {
                    var root = dict._root;

                    if (root != null)
                    {
                        // left == right only if both are nulls
                        if (root.Left == root.Right)
                        {
                            _next = dict._root;
                        }
                        else
                        {
                            _stack = new Stack <AvlNode>(dict.HeightApprox());
                            _stack.Push(dict._root);
                        }
                    }
                }
コード例 #2
0
ファイル: SmallDictionary.cs プロジェクト: zsybupt/roslyn
 public ValueCollection(SmallDictionary <K, V> dict)
 {
     _dict = dict;
 }
コード例 #3
0
ファイル: SmallDictionary.cs プロジェクト: zsybupt/roslyn
 public KeyCollection(SmallDictionary <K, V> dict)
 {
     _dict = dict;
 }
コード例 #4
0
            static void addOptions(
                AnalyzerConfig.Section section,
                TreeOptions.Builder treeBuilder,
                AnalyzerOptions.Builder analyzerBuilder,
                ArrayBuilder <Diagnostic> diagnosticBuilder,
                string analyzerConfigPath,
                SmallDictionary <ReadOnlyMemory <char>, string> diagIdCache)
            {
                const string DiagnosticOptionPrefix = "dotnet_diagnostic.";
                const string DiagnosticOptionSuffix = ".severity";

                foreach (var(key, value) in section.Properties)
                {
                    // Keys are lowercased in editorconfig parsing
                    int diagIdLength = -1;
                    if (key.StartsWith(DiagnosticOptionPrefix, StringComparison.Ordinal) &&
                        key.EndsWith(DiagnosticOptionSuffix, StringComparison.Ordinal))
                    {
                        diagIdLength = key.Length - (DiagnosticOptionPrefix.Length + DiagnosticOptionSuffix.Length);
                    }

                    if (diagIdLength >= 0)
                    {
                        ReadOnlyMemory <char> idSlice = key.AsMemory().Slice(DiagnosticOptionPrefix.Length, diagIdLength);
                        if (!diagIdCache.TryGetValue(idSlice, out var diagId))
                        {
                            diagId = idSlice.ToString();
                            diagIdCache.Add(diagId.AsMemory(), diagId);
                        }

                        ReportDiagnostic?severity;
                        var comparer = StringComparer.OrdinalIgnoreCase;
                        if (comparer.Equals(value, "default"))
                        {
                            severity = ReportDiagnostic.Default;
                        }
                        else if (comparer.Equals(value, "error"))
                        {
                            severity = ReportDiagnostic.Error;
                        }
                        else if (comparer.Equals(value, "warning"))
                        {
                            severity = ReportDiagnostic.Warn;
                        }
                        else if (comparer.Equals(value, "suggestion"))
                        {
                            severity = ReportDiagnostic.Info;
                        }
                        else if (comparer.Equals(value, "silent") || comparer.Equals(value, "refactoring"))
                        {
                            severity = ReportDiagnostic.Hidden;
                        }
                        else if (comparer.Equals(value, "none"))
                        {
                            severity = ReportDiagnostic.Suppress;
                        }
                        else
                        {
                            severity = null;
                            diagnosticBuilder.Add(Diagnostic.Create(
                                                      InvalidAnalyzerConfigSeverityDescriptor,
                                                      Location.None,
                                                      diagId,
                                                      value,
                                                      analyzerConfigPath));
                        }

                        if (severity.HasValue)
                        {
                            treeBuilder[diagId] = severity.GetValueOrDefault();
                        }
                    }
                    else
                    {
                        analyzerBuilder[key] = value;
                    }
                }
            }