Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/convert name of #45806

Merged
merged 164 commits into from
Aug 3, 2020
Merged
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
3868cd4
Initial Set Up
JavierMatosD Jun 23, 2020
1167407
Update CSharpCodeFixes.projitems
JavierMatosD Jun 23, 2020
2e219a6
Revert "Update CSharpCodeFixes.projitems"
JavierMatosD Jun 23, 2020
c100819
Revert "Revert "Update CSharpCodeFixes.projitems""
JavierMatosD Jun 23, 2020
0d32fde
WIP Analyzer, just bare bones diagnostic
Jun 24, 2020
b5a4da9
Merge pull request #45433 from m-redding/feature/convertNameOf
Jun 24, 2020
745419f
Comment
JavierMatosD Jun 24, 2020
01f7a7e
Narrowing analyzer to just .Name instances
Jun 25, 2020
2cbf9cc
Updating analyzer to only report diagnostics on any typeof().Name cases
Jun 26, 2020
a977f28
Only offering the fix for .Name access
Jun 26, 2020
e4b8e80
Merge pull request #45487 from m-redding/feature/convertNameOf
Jun 26, 2020
3307837
add branch name to list of branches that trigger CI
jmarolf Jun 29, 2020
bc79de5
Implemented ConvertNameOfAsync Method
JavierMatosD Jun 29, 2020
d7d831e
whoops
jmarolf Jun 29, 2020
f91233a
Merge remote-tracking branch 'upstream/master' into enable-ci
jmarolf Jun 29, 2020
dd762a6
Merge pull request #45517 from jmarolf/enable-ci
jmarolf Jun 29, 2020
48ac644
adding analysis of generic types
Jun 29, 2020
c55e108
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
Jun 29, 2020
6c5b062
update to ConvertNameOfAsync
JavierMatosD Jul 1, 2020
014b36f
Basic Analyzer with functionality for all cases -- needs testing
Jul 1, 2020
7de92b8
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
Jul 1, 2020
08c7533
Basic analyzer in place -- cleaning up code
Jul 1, 2020
4cf14f3
Update to ConvertNameOfCodeFixProvider
JavierMatosD Jul 1, 2020
6b2af40
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
Jul 6, 2020
fbea8aa
stub ConvertNameOfTests
sigmachirality Jul 6, 2020
41caf10
add basic test
sigmachirality Jul 6, 2020
7b240f9
add LibraryFrameworkType test
sigmachirality Jul 6, 2020
317f930
check for NotOnVariableContainingType
sigmachirality Jul 6, 2020
2dc7b0e
test correct syntax in NotOnVariableContainingType
sigmachirality Jul 6, 2020
4f8c0b9
turns out types are not first class in C#
sigmachirality Jul 6, 2020
2d7d846
add NotOnPrimativeType test
sigmachirality Jul 6, 2020
e47eb81
add ConvertNameOf Trait
sigmachirality Jul 6, 2020
84fccc5
add NotOnGenericType
sigmachirality Jul 6, 2020
4b634a7
add NotOnSimilarStatements
sigmachirality Jul 6, 2020
aef2ae2
Updated convert nameof analyzer
Jul 6, 2020
cf1042c
Merge pull request #45595 from m-redding/feature/convertNameOf
m-redding Jul 6, 2020
fd53ef1
Merge pull request #45698 from sigmachirality/feature/convertNameOf
m-redding Jul 7, 2020
85ad21a
Fixed bug in checking for generic types
Jul 7, 2020
1fce13c
Removing unneccesary helper
Jul 7, 2020
17a1eb3
Update src/Analyzers/CSharp/Analyzers/ConvertNameOf/CSharpConvertName…
m-redding Jul 7, 2020
f2d6294
updating analyzer behavior
Jul 7, 2020
b9f7f3b
Merge branch 'feature/convertNameOf' of https://github.com/m-redding/…
Jul 7, 2020
609111c
Merge pull request #45746 from m-redding/feature/convertNameOf
m-redding Jul 7, 2020
814c904
Check for predefined types
JavierMatosD Jul 7, 2020
0f9323a
Update to ConvertNameOf
JavierMatosD Jul 7, 2020
5dec13c
update tests to account for "using System;" statements
sigmachirality Jul 8, 2020
9ff4902
fix primitiveType test expected
sigmachirality Jul 8, 2020
76daebd
Checks for using directive
JavierMatosD Jul 8, 2020
7135d32
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
JavierMatosD Jul 8, 2020
f98e6dd
Update src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx
m-redding Jul 9, 2020
18df34f
Update src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx
m-redding Jul 9, 2020
e0c50a5
Update src/Analyzers/CSharp/Analyzers/ConvertNameOf/CSharpConvertName…
m-redding Jul 9, 2020
b254a8b
Update src/Analyzers/CSharp/Analyzers/ConvertNameOf/CSharpConvertName…
m-redding Jul 9, 2020
12a3b85
Update src/Analyzers/CSharp/Analyzers/ConvertNameOf/CSharpConvertName…
m-redding Jul 9, 2020
3dd8797
Update src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs
sigmachirality Jul 9, 2020
4a718b0
Update src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs
sigmachirality Jul 9, 2020
32df5c1
update other language resources
sigmachirality Jul 9, 2020
f4318f1
enable nullable in CodeFixProvider
sigmachirality Jul 9, 2020
143c9a8
update tests namespace
sigmachirality Jul 9, 2020
6bfbc6a
update resource access names
sigmachirality Jul 9, 2020
0f584f0
remove nameof
jmarolf Jul 9, 2020
b0dc842
do not add new branches to tests
jmarolf Jul 9, 2020
d280be7
code review updates
Jul 9, 2020
283e805
Merge pull request #45843 from m-redding/feature/convertNameOf
m-redding Jul 9, 2020
5e20546
Update src/Analyzers/CSharp/Analyzers/ConvertNameOf/CSharpConvertName…
sigmachirality Jul 9, 2020
fe90652
add sanity checks for FixAllProvider
sigmachirality Jul 9, 2020
940d59f
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
sigmachirality Jul 9, 2020
f31d6d1
Update to ConvertNameOf
JavierMatosD Jul 9, 2020
3adb4ac
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
JavierMatosD Jul 9, 2020
36d746c
update diagnostic ID
sigmachirality Jul 9, 2020
87262f9
fix typo in FixAllSingleDocumentVaried case
sigmachirality Jul 9, 2020
f9647cd
add TestFixAllInSingleDocumentVariedWithUsing
sigmachirality Jul 9, 2020
e67b42e
simplify FixAll test names
sigmachirality Jul 9, 2020
8cbf58d
Change to ConvertNameOf in CodeFix
JavierMatosD Jul 10, 2020
b43f2be
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
JavierMatosD Jul 10, 2020
8ad139d
Update to CodeFix
JavierMatosD Jul 10, 2020
d876a69
updated comment and added member access check
Jul 10, 2020
ffc47f7
Update to file/folder names
JavierMatosD Jul 10, 2020
b5f1bf9
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
Jul 10, 2020
74f94de
file name updates
Jul 10, 2020
770a9a9
Merge pull request #45880 from m-redding/feature/convertNameOf
m-redding Jul 10, 2020
4d7681c
file updates pt 2
Jul 10, 2020
322ecdc
Merge pull request #45882 from m-redding/feature/convertNameOf
m-redding Jul 10, 2020
8e6ae50
Update to Test cases
JavierMatosD Jul 10, 2020
22106db
fixing file names pt 3
Jul 10, 2020
6b33b39
Merge pull request #45883 from m-redding/feature/convertNameOf
m-redding Jul 10, 2020
4bc1f44
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
JavierMatosD Jul 10, 2020
f677d9b
typo
Jul 10, 2020
aad143b
add new test
Jul 10, 2020
60fef9e
Merge pull request #45887 from m-redding/feature/convertNameOf
m-redding Jul 10, 2020
8414da5
Merge branch 'master' into feature/convertNameOf
jmarolf Jul 13, 2020
cc66f3e
fixup merge
jmarolf Jul 13, 2020
8737cbb
adding VB capability
Jul 13, 2020
53b0327
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
Jul 13, 2020
992e659
rename ConvertNameOfTests -> ConvertTypeOfToNameOfTests
sigmachirality Jul 13, 2020
fbb20d3
Update src/Analyzers/CSharp/Analyzers/ConvertTypeofToNameof/CSharpCon…
sigmachirality Jul 14, 2020
ffd2042
Update src/Analyzers/CSharp/Analyzers/ConvertTypeofToNameof/CSharpCon…
sigmachirality Jul 14, 2020
0bf67b8
Update src/Analyzers/CSharp/Analyzers/ConvertTypeofToNameof/CSharpCon…
sigmachirality Jul 14, 2020
6cf014f
Update src/Analyzers/CSharp/Analyzers/ConvertTypeofToNameof/CSharpCon…
m-redding Jul 15, 2020
9881c09
WIP VB analyzer
Jul 15, 2020
c293198
WIP VB analyzer updates
Jul 15, 2020
6823844
filename updates
Jul 15, 2020
e8e040f
merging changes
Jul 15, 2020
8764e5c
merging changes
Jul 15, 2020
c314265
Update src/Analyzers/CSharp/Analyzers/ConvertTypeofToNameof/CSharpCon…
m-redding Jul 16, 2020
a39821a
Update src/Analyzers/Core/Analyzers/ConvertTypeofToNameof/AbstractCon…
m-redding Jul 16, 2020
5ff316a
update
Jul 16, 2020
4566bb2
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
Jul 16, 2020
a20619a
simple feedback updates
Jul 16, 2020
92f5e16
Implemented VB Side
JavierMatosD Jul 16, 2020
9f5a822
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
JavierMatosD Jul 16, 2020
938d943
Clean up
JavierMatosD Jul 16, 2020
5fb2082
reinclude Unit Tests
sigmachirality Jul 16, 2020
c14a085
Clean up
JavierMatosD Jul 16, 2020
4a9dd4f
simplify test imports
sigmachirality Jul 16, 2020
e1328b3
simplify naming of FixAll tests
sigmachirality Jul 16, 2020
2457239
add Project scope FixAll test
sigmachirality Jul 16, 2020
6c7aab0
add Solution scope FixAll test
sigmachirality Jul 16, 2020
38fc33b
test single-lining multiple statements
sigmachirality Jul 16, 2020
5f1b68a
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
sigmachirality Jul 16, 2020
6ad2723
update trait name from ConvertNameOf to ConvertTypeOfToNameOf
sigmachirality Jul 16, 2020
d41e5a2
Update src/Analyzers/CSharp/CodeFixes/ConvertTypeOfToNameOf/CSharpCon…
sigmachirality Jul 16, 2020
ed3a4d1
add NestedCall case to check that innermost node data is being retrieved
sigmachirality Jul 16, 2020
c7d09f5
oneline method def
sigmachirality Jul 16, 2020
6e35950
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
sigmachirality Jul 16, 2020
a86ee0d
add VB base cases
sigmachirality Jul 16, 2020
8cd6bab
Update Microsoft.CodeAnalysis.Features.csproj
m-redding Jul 17, 2020
3224db9
hopefully resyncing project files
Jul 17, 2020
1acd546
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
Jul 17, 2020
584bf2a
updating analyzer
Jul 17, 2020
61e9b9c
Fix to VB GetSymbolType
JavierMatosD Jul 17, 2020
9379bc1
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
JavierMatosD Jul 17, 2020
aa493ea
fixing test issues
Jul 17, 2020
b1e7385
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
Jul 17, 2020
5a4e321
Clean up
JavierMatosD Jul 17, 2020
8a9210d
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
JavierMatosD Jul 17, 2020
8c4afa0
Removed an Assert from Binder_expressions.VB
JavierMatosD Jul 17, 2020
543122c
typo fix in test case
Jul 20, 2020
628547c
more test case fixes
Jul 20, 2020
9b67d2e
Removed simplifier annotation
JavierMatosD Jul 20, 2020
8d7a33e
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
JavierMatosD Jul 20, 2020
508283d
Fix to Test Cases
JavierMatosD Jul 20, 2020
2f57584
fixing analyzer to report diagnostics differently by language
Jul 20, 2020
ef15272
Merge branch 'feature/convertNameOf' of https://github.com/dotnet/ros…
Jul 20, 2020
1faa5d9
cleaning up
Jul 20, 2020
9d5575c
finishing up different strings for each language functionality
Jul 20, 2020
75171a8
making severity configurable
Jul 21, 2020
5afe3a8
adding functionality for editorconfig preferences
Jul 21, 2020
90732df
Rename AbstractConvertTypeofToNameofDiagnosticAnalyzer.cs to Abstract…
m-redding Jul 21, 2020
6357300
Rename VisualBasicConvertTypeofToNameofDiagnosticAnalyzer.vb to Visua…
m-redding Jul 21, 2020
83c8508
Rename CSharpConvertTypeofToNameofDiagnosticAnalyzer.cs to CSharpConv…
m-redding Jul 21, 2020
eb082e4
trying to fix configurable by editorconfig
Jul 22, 2020
1be898f
updating tests and fixing folder names
Jul 23, 2020
21a3f96
Update CSharpAnalyzers.projitems
m-redding Jul 23, 2020
5f3f2be
Update Analyzers.projitems
m-redding Jul 23, 2020
eba6356
Update VisualBasicAnalyzers.projitems
m-redding Jul 23, 2020
61649b6
remove unnecessary assert
jmarolf Jul 23, 2020
6bbd477
remove unused attribute
jmarolf Jul 23, 2020
9354fc0
add back the assert
jmarolf Jul 23, 2020
1db2273
move resources to language specific locations
jmarolf Jul 24, 2020
1b1ad03
fixup constructor
jmarolf Jul 24, 2020
c80914f
Construct member access expressions in VB
jmarolf Jul 24, 2020
10d7b26
Merge branch 'master' of https://github.com/dotnet/roslyn into featur…
jmarolf Jul 24, 2020
ea09781
fixup resources
jmarolf Aug 3, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Analyzers/CSharp/Analyzers/CSharpAnalyzers.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<Compile Include="$(MSBuildThisFileDirectory)AddAccessibilityModifiers\CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AddRequiredParentheses\CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertTypeOfToNameOf\CSharpConvertTypeOfToNameOfDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnnecessarySuppressions\CSharpRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnnecessarySuppressions\CSharpRemoveUnnecessaryAttributeSuppressionsDiagnosticAnalyzer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RemoveUnnecessaryParentheses\CSharpRemoveUnnecessaryPatternParenthesesDiagnosticAnalyzer.cs" />
Expand Down
5 changes: 4 additions & 1 deletion src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,7 @@
<data name="Suppression_operator_has_no_effect_and_can_be_misinterpreted" xml:space="preserve">
<value>Suppression operator has no effect and can be misinterpreted</value>
</data>
</root>
<data name="Convert_typeof_to_nameof" xml:space="preserve">
<value>Convert 'typeof' to 'nameof'</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.ConvertTypeOfToNameOf;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.Shared.Extensions;

namespace Microsoft.CodeAnalysis.CSharp.ConvertTypeOfToNameOf
{
/// <summary>
/// Finds code like typeof(someType).Name and determines whether it can be changed to nameof(someType), if yes then it offers a diagnostic
/// </summary>
[DiagnosticAnalyzer(LanguageNames.CSharp)]
internal sealed class CSharpConvertTypeOfToNameOfDiagnosticAnalyzer : AbstractConvertTypeOfToNameOfDiagnosticAnalyzer
{
public CSharpConvertTypeOfToNameOfDiagnosticAnalyzer()
{
}

protected override bool IsValidTypeofAction(OperationAnalysisContext context)
{
var node = context.Operation.Syntax;
var syntaxTree = node.SyntaxTree;
// nameof was added in CSharp 6.0, so don't offer it for any languages before that time
if (((CSharpParseOptions)syntaxTree.Options).LanguageVersion < LanguageVersion.CSharp6)
{
return false;
}

// Make sure that the syntax that we're looking at is actually a typeof expression and that
// the parent syntax is a member access expression otherwise the syntax is not the kind of
// expression that we want to analyze
return node is TypeOfExpressionSyntax { Parent: MemberAccessExpressionSyntax _ };
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Převést příkaz switch na výraz</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">Dekonstruovat deklaraci proměnné</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Switch-Anweisung in Ausdruck konvertieren</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">Variablendeklaration dekonstruieren</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Convertir una instrucción switch en expresión</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">Desconstruir la declaración de variable</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Convertir l'instruction switch en expression</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">Déconstruire la déclaration de variable</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Converti l'istruzione switch in espressione</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">Decostruisci la dichiarazione di variabile</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">switch ステートメントを式に変換します</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">変数の宣言を分解</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">switch 문을 식으로 변환</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">변수 선언 분해</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Konwertuj instrukcję switch na wyrażenie</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">Zdekonstruuj deklarację zmiennej</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Converter a instrução switch em expressão</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">Desconstruir declaração de variável</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Преобразовать оператор switch в выражение</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">Деконструировать объявление переменной</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">Switch deyimini ifadeye dönüştür</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">Değişken bildirimini ayrıştır</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">将 switch 语句转换为表达式</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">析构变量声明</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
<target state="translated">將 switch 陳述式轉換為運算式</target>
<note />
</trans-unit>
<trans-unit id="Convert_typeof_to_nameof">
<source>Convert 'typeof' to 'nameof'</source>
<target state="new">Convert 'typeof' to 'nameof'</target>
<note />
</trans-unit>
<trans-unit id="Deconstruct_variable_declaration">
<source>Deconstruct variable declaration</source>
<target state="translated">解構變數宣告</target>
Expand Down
1 change: 1 addition & 0 deletions src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<Compile Include="$(MSBuildThisFileDirectory)AddAccessibilityModifiers\CSharpAddAccessibilityModifiersCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AddBraces\CSharpAddBracesCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertAnonymousTypeToTuple\CSharpConvertAnonymousTypeToTupleCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertTypeOfToNameOf\CSharpConvertTypeOfToNameOfCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.Rewriter.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FileHeaders\CSharpFileHeaderCodeFixProvider.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using System.Composition;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.ConvertTypeOfToNameOf;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Shared.Extensions;

namespace Microsoft.CodeAnalysis.CSharp.ConvertTypeOfToNameOf
{
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(CSharpConvertTypeOfToNameOfCodeFixProvider)), Shared]
internal class CSharpConvertTypeOfToNameOfCodeFixProvider : AbstractConvertTypeOfToNameOfCodeFixProvider
{
[ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
public CSharpConvertTypeOfToNameOfCodeFixProvider()
{
}

protected override ITypeSymbol? GetSymbolType(SyntaxNode node, SemanticModel model)
{
if (node is MemberAccessExpressionSyntax memberAccess)
{
var expression = memberAccess.Expression;
if (expression is TypeOfExpressionSyntax typeOfExpresison)
JavierMatosD marked this conversation as resolved.
Show resolved Hide resolved
{
return model.GetSymbolInfo(typeOfExpresison.Type).Symbol.GetSymbolType();
}

return null;
}
return null;
sigmachirality marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<Compile Include="$(MSBuildThisFileDirectory)AddRequiredParentheses\AddRequiredPatternParenthesesTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)AddRequiredParentheses\AddRequiredExpressionParenthesesTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertAnonymousTypeToTuple\ConvertAnonymousTypeToTupleTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertTypeOfToNameOf\ConvertTypeOfToNameOfFixAllTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ConvertTypeOfToNameOf\ConvertTypeOfToNameOfTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)InlineDeclaration\CSharpInlineDeclarationTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)InlineDeclaration\CSharpInlineDeclarationTests_FixAllTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessTests.cs" />
Expand Down Expand Up @@ -97,4 +99,7 @@
<ItemGroup Condition="'$(DefaultLanguageSourceExtension)' != '' AND '$(BuildingInsideVisualStudio)' != 'true'">
<ExpectedCompile Include="$(MSBuildThisFileDirectory)**\*$(DefaultLanguageSourceExtension)" />
</ItemGroup>
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)ConvertTypeOfToNameOf\" />
</ItemGroup>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believ eyou should be able to remove this safely

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

</Project>
Loading