Skip to content

Commit 692e605

Browse files
committed
add refactoring for switch/map for generation of method args
1 parent fbad0a9 commit 692e605

File tree

40 files changed

+2403
-43
lines changed

40 files changed

+2403
-43
lines changed

.claude/CLAUDE.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,11 @@ SyntaxProvider (filter by attribute via ForAttributeWithMetadataName)
153153
| `ObjectFactorySourceGenerator` | `ObjectFactorySourceGeneratorState` | `ObjectFactoryCodeGenerator` |
154154
| `AnnotationsSourceGenerator` || JetBrains annotations |
155155

156-
### Analyzers
156+
### Analyzers & Refactorings
157157

158158
1. `ThinktectureRuntimeExtensionsAnalyzer` -- 56 diagnostic rules (`TTRESG` prefix) for correct usage
159159
2. `ThinktectureRuntimeExtensionsInternalUsageAnalyzer` -- Prevents external use of internal APIs
160+
3. `SwitchMapCompletionRefactoringProvider` -- IDE refactoring (light bulb action) that auto-generates arguments for `Switch`/`Map`/`SwitchPartially`/`MapPartially` method calls on Smart Enums and Unions
160161

161162
### Runtime Metadata
162163

@@ -175,7 +176,11 @@ Generated types implement `IMetadataOwner`. At runtime, `MetadataLookup` (in `Th
175176

176177
- **`src/Thinktecture.Runtime.Extensions`** -- Core library (interfaces, attributes, runtime helpers)
177178
- **`src/Thinktecture.Runtime.Extensions.SourceGenerator`** -- Source Generators and Analyzers
179+
- **`src/Thinktecture.Runtime.Extensions.Refactorings`** -- Roslyn code refactorings (IDE light-bulb actions)
180+
- **`src/Thinktecture.Runtime.Extensions.Roslyn.Sources`** -- Shared Roslyn source files compiled into both SourceGenerator and Refactorings (via `<Compile Include>`, not a project reference)
178181
- **Framework Integration** -- `.Json`, `.MessagePack`, `.Newtonsoft`, `.EntityFrameworkCore8/9/10`, `.AspNetCore`, `.Swashbuckle`
182+
- **`test/Thinktecture.Runtime.Extensions.Tests.Shared`** -- Shared test types (Smart Enums, Value Objects, Unions) and string utilities, referenced by all test projects
183+
- **`test/Thinktecture.Runtime.Extensions.RoslynTests.Shared`** -- Shared Roslyn test infrastructure (nullable warning handling), referenced by SourceGenerator.Tests and Refactorings.Tests
179184

180185
### Key Files
181186

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
- name: build source generator
3838
run: dotnet build --configuration Release --no-restore src/Thinktecture.Runtime.Extensions.SourceGenerator/Thinktecture.Runtime.Extensions.SourceGenerator.csproj
3939

40+
- name: build source refactorings
41+
run: dotnet build --configuration Release --no-restore src/Thinktecture.Runtime.Extensions.Refactorings/Thinktecture.Runtime.Extensions.Refactorings.csproj
42+
4043
- name: build
4144
run: dotnet build --configuration Release --no-restore
4245

Directory.Packages.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
<PackageVersion Include="MessagePack" Version="2.5.198" />
99
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="10.0.1" />
1010
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="10.0.1" />
11+
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzer.Testing" Version="1.1.2" />
1112
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
1213
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Analyzer.Testing" Version="1.1.2" />
1314
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.2" />
15+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing" Version="1.1.2" />
1416
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.SourceGenerators.Testing" Version="1.1.2" />
1517
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.0.0" />
1618
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.11" />

Thinktecture.Runtime.Extensions.slnx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<Project Path="src/Thinktecture.Runtime.Extensions.Json/Thinktecture.Runtime.Extensions.Json.csproj" />
5959
<Project Path="src/Thinktecture.Runtime.Extensions.MessagePack/Thinktecture.Runtime.Extensions.MessagePack.csproj" />
6060
<Project Path="src/Thinktecture.Runtime.Extensions.Newtonsoft.Json/Thinktecture.Runtime.Extensions.Newtonsoft.Json.csproj" />
61+
<Project Path="src/Thinktecture.Runtime.Extensions.Refactorings/Thinktecture.Runtime.Extensions.Refactorings.csproj" />
6162
<Project Path="src/Thinktecture.Runtime.Extensions.SourceGenerator/Thinktecture.Runtime.Extensions.SourceGenerator.csproj" />
6263
<Project Path="src/Thinktecture.Runtime.Extensions.Swashbuckle/Thinktecture.Runtime.Extensions.Swashbuckle.csproj" />
6364
<Project Path="src/Thinktecture.Runtime.Extensions/Thinktecture.Runtime.Extensions.csproj" />
@@ -72,6 +73,8 @@
7273
<Project Path="test/Thinktecture.Runtime.Extensions.Json.Tests/Thinktecture.Runtime.Extensions.Json.Tests.csproj" />
7374
<Project Path="test/Thinktecture.Runtime.Extensions.MessagePack.Tests/Thinktecture.Runtime.Extensions.MessagePack.Tests.csproj" />
7475
<Project Path="test/Thinktecture.Runtime.Extensions.Newtonsoft.Json.Tests/Thinktecture.Runtime.Extensions.Newtonsoft.Json.Tests.csproj" />
76+
<Project Path="test/Thinktecture.Runtime.Extensions.Refactorings.Tests/Thinktecture.Runtime.Extensions.Refactorings.Tests.csproj" />
77+
<Project Path="test/Thinktecture.Runtime.Extensions.RoslynTests.Shared/Thinktecture.Runtime.Extensions.RoslynTests.Shared.csproj" />
7578
<Project Path="test/Thinktecture.Runtime.Extensions.SourceGenerator.Tests/Thinktecture.Runtime.Extensions.SourceGenerator.Tests.csproj" />
7679
<Project Path="test/Thinktecture.Runtime.Extensions.Swashbuckle.3_0.Tests/Thinktecture.Runtime.Extensions.Swashbuckle.3_0.Tests.csproj" />
7780
<Project Path="test/Thinktecture.Runtime.Extensions.Swashbuckle.3_1.Tests/Thinktecture.Runtime.Extensions.Swashbuckle.3_1.Tests.csproj" />

docs

Submodule docs updated from fbabfcb to ae479e6

samples/AspNetCore.Samples/AspNetCore.Samples.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@
2424
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.Json\Thinktecture.Runtime.Extensions.Json.csproj" />
2525
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.Swashbuckle\Thinktecture.Runtime.Extensions.Swashbuckle.csproj" />
2626
<ProjectReference Include="..\Basic.Samples\Basic.Samples.csproj" />
27-
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.SourceGenerator\Thinktecture.Runtime.Extensions.SourceGenerator.csproj" SetTargetFramework="TargetFramework=netstandard2.0" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
27+
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.SourceGenerator\Thinktecture.Runtime.Extensions.SourceGenerator.csproj"
28+
SetTargetFramework="TargetFramework=netstandard2.0"
29+
ReferenceOutputAssembly="false"
30+
OutputItemType="Analyzer" />
31+
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.Refactorings\Thinktecture.Runtime.Extensions.Refactorings.csproj"
32+
SetTargetFramework="TargetFramework=netstandard2.0"
33+
ReferenceOutputAssembly="false"
34+
OutputItemType="Analyzer" />
2835
</ItemGroup>
2936

3037
</Project>

samples/Basic.Samples/Basic.Samples.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@
99
<ItemGroup>
1010
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions\Thinktecture.Runtime.Extensions.csproj" />
1111
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.Json\Thinktecture.Runtime.Extensions.Json.csproj" />
12-
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.SourceGenerator\Thinktecture.Runtime.Extensions.SourceGenerator.csproj" SetTargetFramework="TargetFramework=netstandard2.0" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
12+
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.SourceGenerator\Thinktecture.Runtime.Extensions.SourceGenerator.csproj"
13+
SetTargetFramework="TargetFramework=netstandard2.0"
14+
ReferenceOutputAssembly="false"
15+
OutputItemType="Analyzer" />
16+
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.Refactorings\Thinktecture.Runtime.Extensions.Refactorings.csproj"
17+
SetTargetFramework="TargetFramework=netstandard2.0"
18+
ReferenceOutputAssembly="false"
19+
OutputItemType="Analyzer" />
1320
</ItemGroup>
1421
<ItemGroup>
1522
<PackageReference Include="CsvHelper" />

samples/Benchmarking/Benchmarking.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,14 @@
1818
<ItemGroup>
1919
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.EntityFrameworkCore9\Thinktecture.Runtime.Extensions.EntityFrameworkCore9.csproj" />
2020
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.Json\Thinktecture.Runtime.Extensions.Json.csproj" />
21-
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.SourceGenerator\Thinktecture.Runtime.Extensions.SourceGenerator.csproj" SetTargetFramework="TargetFramework=netstandard2.0" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
21+
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.SourceGenerator\Thinktecture.Runtime.Extensions.SourceGenerator.csproj"
22+
SetTargetFramework="TargetFramework=netstandard2.0"
23+
ReferenceOutputAssembly="false"
24+
OutputItemType="Analyzer" />
25+
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.Refactorings\Thinktecture.Runtime.Extensions.Refactorings.csproj"
26+
SetTargetFramework="TargetFramework=netstandard2.0"
27+
ReferenceOutputAssembly="false"
28+
OutputItemType="Analyzer" />
2229
</ItemGroup>
2330

2431
<ItemGroup>

samples/EntityFrameworkCore.Samples/EntityFrameworkCore.Samples.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66
<ItemGroup>
77
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.EntityFrameworkCore8\Thinktecture.Runtime.Extensions.EntityFrameworkCore8.csproj" />
88
<ProjectReference Include="..\Basic.Samples\Basic.Samples.csproj" />
9-
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.SourceGenerator\Thinktecture.Runtime.Extensions.SourceGenerator.csproj" SetTargetFramework="TargetFramework=netstandard2.0" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
9+
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.SourceGenerator\Thinktecture.Runtime.Extensions.SourceGenerator.csproj"
10+
SetTargetFramework="TargetFramework=netstandard2.0"
11+
ReferenceOutputAssembly="false"
12+
OutputItemType="Analyzer" />
13+
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.Refactorings\Thinktecture.Runtime.Extensions.Refactorings.csproj"
14+
SetTargetFramework="TargetFramework=netstandard2.0"
15+
ReferenceOutputAssembly="false"
16+
OutputItemType="Analyzer" />
1017
</ItemGroup>
1118
<ItemGroup>
1219
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" />

samples/MessagePack.Samples/MessagePack.Samples.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
<ItemGroup>
66
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.MessagePack\Thinktecture.Runtime.Extensions.MessagePack.csproj" />
77
<ProjectReference Include="..\Basic.Samples\Basic.Samples.csproj" />
8-
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.SourceGenerator\Thinktecture.Runtime.Extensions.SourceGenerator.csproj" SetTargetFramework="TargetFramework=netstandard2.0" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
8+
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.SourceGenerator\Thinktecture.Runtime.Extensions.SourceGenerator.csproj"
9+
SetTargetFramework="TargetFramework=netstandard2.0"
10+
ReferenceOutputAssembly="false"
11+
OutputItemType="Analyzer" />
12+
<ProjectReference Include="..\..\src\Thinktecture.Runtime.Extensions.Refactorings\Thinktecture.Runtime.Extensions.Refactorings.csproj"
13+
SetTargetFramework="TargetFramework=netstandard2.0"
14+
ReferenceOutputAssembly="false"
15+
OutputItemType="Analyzer" />
916
</ItemGroup>
1017
</Project>

0 commit comments

Comments
 (0)