Skip to content

Commit

Permalink
Address final review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed Jun 4, 2020
1 parent 36ae247 commit 5493e1b
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 79 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Immutable;
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
using Analyzer.Utilities;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Rename;
using Roslyn.Diagnostics.Analyzers;
Expand All @@ -24,7 +23,7 @@ public override FixAllProvider GetFixAllProvider()

public override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
var title = RoslynDiagnosticsAnalyzersResources.AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle;
var title = RoslynDiagnosticsAnalyzersResources.AvoidOptSuffixForNullableEnableCodeCodeFixTitle;

foreach (var diagnostic in context.Diagnostics)
{
Expand All @@ -48,7 +47,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
if (semanticModel.LookupSymbols(diagnostic.Location.SourceSpan.Start, variableSymbol.ContainingType, newName).IsEmpty)
{
context.RegisterCodeFix(
new MyCodeAction(
CodeAction.Create(
title,
cancellationToken => RemoveOptSuffixOnVariableAsync(context.Document, variableSymbol, newName, cancellationToken),
equivalenceKey: title),
Expand All @@ -60,14 +59,5 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
private static async Task<Solution> RemoveOptSuffixOnVariableAsync(Document document, ISymbol variableSymbol, string newName, CancellationToken cancellationToken)
=> await Renamer.RenameSymbolAsync(document.Project.Solution, variableSymbol, newName, document.Project.Solution.Options, cancellationToken)
.ConfigureAwait(false);

// Needed for Telemetry (https://github.com/dotnet/roslyn/issues/4919)
private class MyCodeAction : SolutionChangeAction
{
public MyCodeAction(string title, Func<CancellationToken, Task<Solution>> createChangedSolution, string equivalenceKey)
: base(title, createChangedSolution, equivalenceKey)
{
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
<data name="Place_statement_on_following_line" xml:space="preserve">
<value>Place statement on following line</value>
</data>
<data name="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle" xml:space="preserve">
<data name="AvoidOptSuffixForNullableEnableCodeCodeFixTitle" xml:space="preserve">
<value>Remove the 'Opt' suffix</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="cs" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="de" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="es" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="fr" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="it" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ja" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ko" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pl" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="pt-BR" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="ru" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="tr" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.2" xsi:schemaLocation="urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd">
<file datatype="xml" source-language="en" target-language="zh-HANS" original="../RoslynDiagnosticsAnalyzersResources.resx">
<body>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeDescription">
<source>Avoid the 'Opt' suffix in a nullable-enabled code.</source>
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code.</target>
Expand All @@ -12,11 +17,6 @@
<target state="new">Avoid the 'Opt' suffix in a nullable-enabled code</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeRuleIdTitleCodeFixTitle">
<source>Remove the 'Opt' suffix</source>
<target state="new">Remove the 'Opt' suffix</target>
<note />
</trans-unit>
<trans-unit id="AvoidOptSuffixForNullableEnableCodeTitle">
<source>Avoid the 'Opt' suffix</source>
<target state="new">Avoid the 'Opt' suffix</target>
Expand Down
Loading

0 comments on commit 5493e1b

Please sign in to comment.