Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Rename code fixer project to CommunityToolkit.Mvvm.CodeFixers
  • Loading branch information
Sergio0694 committed Jan 23, 2023
commit e7a79c3c5bc2ea56b7789210ef5be8098b6b6840
2 changes: 1 addition & 1 deletion dotnet Community Toolkit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Mvvm.Exter
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Mvvm.ExternalAssembly.Roslyn431", "tests\CommunityToolkit.Mvvm.ExternalAssembly.Roslyn431\CommunityToolkit.Mvvm.ExternalAssembly.Roslyn431.csproj", "{4FCD501C-1BB5-465C-AD19-356DAB6600C6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Mvvm.Fixers", "src\CommunityToolkit.Mvvm.Fixers\CommunityToolkit.Mvvm.Fixers.csproj", "{E79DCA2A-4C59-499F-85BD-F45215ED6B72}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Mvvm.CodeFixers", "src\CommunityToolkit.Mvvm.CodeFixers\CommunityToolkit.Mvvm.CodeFixers.csproj", "{E79DCA2A-4C59-499F-85BD-F45215ED6B72}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;

namespace CommunityToolkit.Mvvm.Fixers;
namespace CommunityToolkit.Mvvm.CodeFixers;

/// <summary>
/// A code fixer that automatically updates references to fields with <c>[ObservableProperty]</c> to reference the generated property instead.
/// </summary>
[ExportCodeFixProvider(LanguageNames.CSharp)]
[Shared]
public sealed class FieldReferenceForObservablePropertyFieldFixer : CodeFixProvider
public sealed class FieldReferenceForObservablePropertyFieldCodeFixer : CodeFixProvider
{
/// <inheritdoc/>
public override ImmutableArray<string> FixableDiagnosticIds { get; } = ImmutableArray.Create(DiagnosticDescriptors.FieldReferenceForObservablePropertyFieldId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

<!-- Give access to the code fixers project for the exported diagnostic ids and properties -->
<ItemGroup>
<InternalsVisibleTo Include="CommunityToolkit.Mvvm.Fixers, PublicKey=$(AssemblySignPublicKey)" />
<InternalsVisibleTo Include="CommunityToolkit.Mvvm.CodeFixers, PublicKey=$(AssemblySignPublicKey)" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions src/CommunityToolkit.Mvvm/CommunityToolkit.Mvvm.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<ProjectReference Include="..\CommunityToolkit.Mvvm.SourceGenerators.Roslyn401\CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\CommunityToolkit.Mvvm.SourceGenerators.Roslyn431\CommunityToolkit.Mvvm.SourceGenerators.Roslyn431.csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\CommunityToolkit.Mvvm.Fixers\CommunityToolkit.Mvvm.Fixers.csproj" ReferenceOutputAssembly="false" />
<ProjectReference Include="..\CommunityToolkit.Mvvm.CodeFixers\CommunityToolkit.Mvvm.CodeFixers.csproj" ReferenceOutputAssembly="false" />
</ItemGroup>

<!-- Add the [InternalsVisibleTo] attribute for the test project -->
Expand Down Expand Up @@ -83,8 +83,8 @@
-->
<None Include="..\CommunityToolkit.Mvvm.SourceGenerators.Roslyn401\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.SourceGenerators.dll" PackagePath="analyzers\dotnet\roslyn4.0\cs" Pack="true" Visible="false" />
<None Include="..\CommunityToolkit.Mvvm.SourceGenerators.Roslyn431\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.SourceGenerators.dll" PackagePath="analyzers\dotnet\roslyn4.3\cs" Pack="true" Visible="false" />
<None Include="..\CommunityToolkit.Mvvm.Fixers\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.Fixers.dll" PackagePath="analyzers\dotnet\roslyn4.0\cs" Pack="true" Visible="false" />
<None Include="..\CommunityToolkit.Mvvm.Fixers\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.Fixers.dll" PackagePath="analyzers\dotnet\roslyn4.3\cs" Pack="true" Visible="false" />
<None Include="..\CommunityToolkit.Mvvm.CodeFixers\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.CodeFixers.dll" PackagePath="analyzers\dotnet\roslyn4.0\cs" Pack="true" Visible="false" />
<None Include="..\CommunityToolkit.Mvvm.CodeFixers\bin\$(Configuration)\netstandard2.0\CommunityToolkit.Mvvm.CodeFixers.dll" PackagePath="analyzers\dotnet\roslyn4.3\cs" Pack="true" Visible="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\CommunityToolkit.Mvvm\CommunityToolkit.Mvvm.csproj" />
<ProjectReference Include="..\..\src\CommunityToolkit.Mvvm.Fixers\CommunityToolkit.Mvvm.Fixers.csproj" />
<ProjectReference Include="..\..\src\CommunityToolkit.Mvvm.CodeFixers\CommunityToolkit.Mvvm.CodeFixers.csproj" />
<ProjectReference Include="..\..\src\CommunityToolkit.Mvvm.SourceGenerators.Roslyn401\CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.CodeAnalysis.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Test = Microsoft.CodeAnalysis.CSharp.Testing.CSharpCodeFixTest<
using CSharpCodeFixTest = Microsoft.CodeAnalysis.CSharp.Testing.CSharpCodeFixTest<
CommunityToolkit.Mvvm.SourceGenerators.FieldReferenceForObservablePropertyFieldAnalyzer,
CommunityToolkit.Mvvm.Fixers.FieldReferenceForObservablePropertyFieldFixer,
CommunityToolkit.Mvvm.CodeFixers.FieldReferenceForObservablePropertyFieldCodeFixer,
Microsoft.CodeAnalysis.Testing.Verifiers.MSTestVerifier>;
using VerifyCS = Microsoft.CodeAnalysis.CSharp.Testing.CSharpCodeFixVerifier<
using CSharpCodeFixVerifier = Microsoft.CodeAnalysis.CSharp.Testing.CSharpCodeFixVerifier<
CommunityToolkit.Mvvm.SourceGenerators.FieldReferenceForObservablePropertyFieldAnalyzer,
CommunityToolkit.Mvvm.Fixers.FieldReferenceForObservablePropertyFieldFixer,
CommunityToolkit.Mvvm.CodeFixers.FieldReferenceForObservablePropertyFieldCodeFixer,
Microsoft.CodeAnalysis.Testing.Verifiers.MSTestVerifier>;

namespace CommunityToolkit.Mvvm.SourceGenerators.Roslyn401.UnitTests;

[TestClass]
public class Test_FieldReferenceForObservablePropertyFieldFixer
public class Test_FieldReferenceForObservablePropertyFieldCodeFixer
{
[TestMethod]
public async Task SimpleMemberAccess()
Expand Down Expand Up @@ -55,7 +55,7 @@ void M()
}
""";

Test test = new()
CSharpCodeFixTest test = new()
{
TestCode = original,
FixedCode = @fixed,
Expand All @@ -66,10 +66,10 @@ void M()
test.ExpectedDiagnostics.AddRange(new[]
{
// /0/Test0.cs(10,13): warning MVVMTK0034: The field C.i is annotated with [ObservableProperty] and should not be directly referenced (use the generated property instead)
VerifyCS.Diagnostic().WithSpan(10, 13, 10, 14).WithArguments("C.i"),
CSharpCodeFixVerifier.Diagnostic().WithSpan(10, 13, 10, 14).WithArguments("C.i"),

// /0/Test0.cs(11,9): warning MVVMTK0034: The field C.i is annotated with [ObservableProperty] and should not be directly referenced (use the generated property instead)
VerifyCS.Diagnostic().WithSpan(11, 9, 11, 10).WithArguments("C.i")
CSharpCodeFixVerifier.Diagnostic().WithSpan(11, 9, 11, 10).WithArguments("C.i")
});

test.FixedState.ExpectedDiagnostics.AddRange(new[]
Expand Down Expand Up @@ -119,7 +119,7 @@ void M()
}
""";

Test test = new()
CSharpCodeFixTest test = new()
{
TestCode = original,
FixedCode = @fixed,
Expand All @@ -130,10 +130,10 @@ void M()
test.ExpectedDiagnostics.AddRange(new[]
{
// /0/Test0.cs(10,13): warning MVVMTK0034: The field C.i is annotated with [ObservableProperty] and should not be directly referenced (use the generated property instead)
VerifyCS.Diagnostic().WithSpan(10, 13, 10, 19).WithArguments("C.i"),
CSharpCodeFixVerifier.Diagnostic().WithSpan(10, 13, 10, 19).WithArguments("C.i"),

// /0/Test0.cs(11,9): warning MVVMTK0034: The field C.i is annotated with [ObservableProperty] and should not be directly referenced (use the generated property instead)
VerifyCS.Diagnostic().WithSpan(11, 9, 11, 15).WithArguments("C.i"),
CSharpCodeFixVerifier.Diagnostic().WithSpan(11, 9, 11, 15).WithArguments("C.i"),
});

test.FixedState.ExpectedDiagnostics.AddRange(new[]
Expand Down Expand Up @@ -191,7 +191,7 @@ void M()
}
""";

Test test = new()
CSharpCodeFixTest test = new()
{
TestCode = original,
FixedCode = @fixed,
Expand All @@ -202,10 +202,10 @@ void M()
test.ExpectedDiagnostics.AddRange(new[]
{
// /0/Test0.cs(14,9): warning MVVMTK0034: The field C.i is annotated with [ObservableProperty] and should not be directly referenced (use the generated property instead)
VerifyCS.Diagnostic().WithSpan(14, 9, 14, 12).WithArguments("C.i"),
CSharpCodeFixVerifier.Diagnostic().WithSpan(14, 9, 14, 12).WithArguments("C.i"),

// /0/Test0.cs(15,13): warning MVVMTK0034: The field C.i is annotated with [ObservableProperty] and should not be directly referenced (use the generated property instead)
VerifyCS.Diagnostic().WithSpan(15, 13, 15, 16).WithArguments("C.i"),
CSharpCodeFixVerifier.Diagnostic().WithSpan(15, 13, 15, 16).WithArguments("C.i"),
});

test.FixedState.ExpectedDiagnostics.AddRange(new[]
Expand Down Expand Up @@ -261,7 +261,7 @@ void M()
}
""";

Test test = new()
CSharpCodeFixTest test = new()
{
TestCode = original,
FixedCode = @fixed,
Expand All @@ -272,7 +272,7 @@ void M()
test.ExpectedDiagnostics.AddRange(new[]
{
// /0/Test0.cs(14,15): warning MVVMTK0034: The field C.i is annotated with [ObservableProperty] and should not be directly referenced (use the generated property instead)
VerifyCS.Diagnostic().WithSpan(14, 15, 14, 17).WithArguments("C.i"),
CSharpCodeFixVerifier.Diagnostic().WithSpan(14, 15, 14, 17).WithArguments("C.i"),
});

test.FixedState.ExpectedDiagnostics.AddRange(new[]
Expand Down