Exemplo n.º 1
0
                static IEnumerable <KeyValuePair <CodeFixIdentifier, bool> > LoadCodeFixes()
                {
                    foreach (KeyValuePair <string, bool> kvp in CodeAnalysisConfiguration.Default.CodeFixes)
                    {
                        string id        = kvp.Key;
                        bool   isEnabled = kvp.Value;

                        if (CodeFixIdentifier.TryParse(id, out CodeFixIdentifier codeFixIdentifier))
                        {
                            yield return(new KeyValuePair <CodeFixIdentifier, bool>(codeFixIdentifier, isEnabled));
                        }
                        else if (id.StartsWith(CodeFixIdentifier.CodeFixIdPrefix, StringComparison.Ordinal))
                        {
                            foreach (string compilerDiagnosticId in CodeFixMap.GetCompilerDiagnosticIds(id))
                            {
                                yield return(new KeyValuePair <CodeFixIdentifier, bool>(new CodeFixIdentifier(compilerDiagnosticId, id), isEnabled));
                            }
                        }
                        else if (id.StartsWith("CS", StringComparison.Ordinal))
                        {
                            foreach (string codeFixId in CodeFixMap.GetCodeFixIds(id))
                            {
                                yield return(new KeyValuePair <CodeFixIdentifier, bool>(new CodeFixIdentifier(id, codeFixId), isEnabled));
                            }
                        }
                        else
                        {
                            Debug.Fail(id);
                        }
                    }
                }
Exemplo n.º 2
0
        protected override void Fill(ICollection <BaseModel> items)
        {
            items.Clear();

            foreach (CompilerDiagnosticFix compilerDiagnosticFix in CodeFixMap.GetCompilerDiagnosticFixes()
                     .OrderBy(f => f.CompilerDiagnosticId)
                     .ThenBy(f => f.CodeFixId))
            {
                var model = new CodeFixModel(
                    compilerDiagnosticFix.CompilerDiagnosticId,
                    compilerDiagnosticFix.CompilerDiagnosticTitle,
                    compilerDiagnosticFix.CodeFixId,
                    compilerDiagnosticFix.CodeFixTitle);

                model.Enabled = IsEnabled(model.Id);

                items.Add(model);
            }
        }
Exemplo n.º 3
0
        protected override void SetValues(CodeAnalysisConfiguration configuration)
        {
            if (configuration == null)
            {
                return;
            }

            foreach (KeyValuePair <string, bool> kvp in configuration.CodeFixes)
            {
                string id        = kvp.Key;
                bool   isEnabled = kvp.Value;

                if (CodeFixIdentifier.TryParse(id, out CodeFixIdentifier codeFixIdentifier))
                {
                    Set(codeFixIdentifier, isEnabled);
                }
                else if (id.StartsWith(CodeFixIdentifier.CodeFixIdPrefix, StringComparison.Ordinal))
                {
                    foreach (string compilerDiagnosticId in CodeFixMap.GetCompilerDiagnosticIds(id))
                    {
                        Set(new CodeFixIdentifier(compilerDiagnosticId, id), isEnabled);
                    }
                }
                else if (id.StartsWith("CS", StringComparison.Ordinal))
                {
                    foreach (string codeFixId in CodeFixMap.GetCodeFixIds(id))
                    {
                        Set(new CodeFixIdentifier(id, codeFixId), isEnabled);
                    }
                }
                else
                {
                    Debug.Fail(id);
                }
            }
        }