File tree Expand file tree Collapse file tree
StructId.Analyzer/Properties Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- namespace Sample ;
1+ using StructId ;
2+
3+ namespace Sample ;
24
35public record Product ( ProductId Id , string Name ) ;
46
Original file line number Diff line number Diff line change 1- using ConsoleDb ;
2- using Dapper ;
1+ using Dapper ;
32using Microsoft . Data . Sqlite ;
3+ using StructId ;
44
55SQLitePCL . Batteries . Init ( ) ;
66
Original file line number Diff line number Diff line change 1+ <Project >
2+ <Import Project =" ..\Directory.Build.props" />
3+
4+ <PropertyGroup >
5+ <FromSource >false</FromSource >
6+ <FromSource Condition =" $(SolutionName) == 'StructId'" >true</FromSource >
7+ </PropertyGroup >
8+
9+ </Project >
Original file line number Diff line number Diff line change 1+ <Project >
2+ <Import Project =" ..\Directory.Build.targets" />
3+
4+ <PropertyGroup >
5+ <AfterMicrosoftNETSdkTargets >$(AfterMicrosoftNETSdkTargets);$(MSBuildThisFileDirectory)..\StructId.Package\StructId.targets</AfterMicrosoftNETSdkTargets >
6+ </PropertyGroup >
7+
8+ <ItemGroup Condition =" $(FromSource)" >
9+ <PackageReference Remove =" StructId" />
10+ <PackageReference Include =" Scriban" Version =" 5.12.1" GeneratePathProperty =" true" />
11+
12+ <ProjectReference Include =" $(MSBuildThisFileDirectory)..\StructId.Analyzer\StructId.Analyzer.csproj" OutputItemType =" Analyzer" />
13+ <ProjectReference Include =" $(MSBuildThisFileDirectory)..\StructId.CodeFix\StructId.CodeFix.csproj" OutputItemType =" Analyzer" />
14+ <ProjectReference Include =" $(MSBuildThisFileDirectory)..\StructId.Package\StructId.Package.msbuildproj" ReferenceOutputAssembly =" false" />
15+
16+ <Analyzer Include =" $(PkgScriban)/lib/netstandard2.0/Scriban.dll" Condition =" Exists('$(PkgScriban)/lib/netstandard2.0/Scriban.dll')" />
17+ </ItemGroup >
18+
19+ <Target Name =" FromSource" Condition =" $(FromSource)" BeforeTargets =" AddStructId" >
20+ <ItemGroup >
21+ <!-- These would be added from the package-relative paths by the StructId.targets -->
22+ <StructIdCompile Include =" $(MSBuildThisFileDirectory)..\StructId\*.cs" />
23+ <StructIdTemplates Include =" $(MSBuildThisFileDirectory)..\StructId\Templates\*.cs" />
24+ </ItemGroup >
25+
26+ <ItemGroup >
27+ <!-- Templates should always be added by buildTransitive targets -->
28+ <StructId Include =" @(StructIdTemplates)" Link =" StructId\Templates\%(StructIdTemplates.Filename)%(StructIdTemplates.Extension)" />
29+ </ItemGroup >
30+
31+ <ItemGroup Condition =" '$(HasStructIdReference)' != 'false'" >
32+ <StructId Include =" @(StructIdCompile)" Link =" StructId\%(StructIdCompile.Filename)%(StructIdCompile.Extension)" />
33+ </ItemGroup >
34+ </Target >
35+
36+ </Project >
Original file line number Diff line number Diff line change 66 <ImplicitUsings >enable</ImplicitUsings >
77 <RestoreSources >https://api.nuget.org/v3/index.json;$(PackageOutputPath)</RestoreSources >
88 <EmitCompilerGeneratedFiles >true</EmitCompilerGeneratedFiles >
9+ <HasStructIdReference >false</HasStructIdReference >
910 </PropertyGroup >
1011
1112 <ItemGroup >
Original file line number Diff line number Diff line change 11using Sample ;
2+ using StructId ;
23
34var builder = WebApplication . CreateBuilder ( args ) ;
45var app = builder . Build ( ) ;
89
910app . Run ( ) ;
1011
11- readonly partial record struct UserId : IStructId < int > ;
12+ readonly partial record struct UserId ( int Value ) : IStructId < int > ;
1213
1314record User ( UserId id , string Alias ) ;
Original file line number Diff line number Diff line change 11using Microsoft . AspNetCore . Mvc ;
22using Sample ;
3+ using StructId ;
34
45namespace MvcWebApplication . Controllers ;
56
@@ -24,6 +25,6 @@ public IActionResult GetProduct(ProductId? id)
2425 }
2526}
2627
27- public readonly partial record struct UserId : IStructId < Guid > ;
28+ public readonly partial record struct UserId : IStructId < Ulid > ;
2829
2930public record User ( UserId id , string Alias ) ;
Original file line number Diff line number Diff line change 66 <ImplicitUsings >enable</ImplicitUsings >
77 <RestoreSources >https://api.nuget.org/v3/index.json;$(PackageOutputPath)</RestoreSources >
88 <EmitCompilerGeneratedFiles >true</EmitCompilerGeneratedFiles >
9+ <HasStructIdReference >false</HasStructIdReference >
910 </PropertyGroup >
1011
12+ <ItemGroup >
13+ <PackageReference Include =" Ulid" Version =" 1.3.4" />
14+ </ItemGroup >
15+
1116 <ItemGroup >
1217 <ProjectReference Include =" ..\Common\Common.csproj" />
1318 </ItemGroup >
Original file line number Diff line number Diff line change 33 "Roslyn" : {
44 "commandName" : " DebugRoslynComponent" ,
55 "targetProject" : " ..\\ StructId.FunctionalTests\\ StructId.FunctionalTests.csproj"
6+ },
7+ "MinimalApi" : {
8+ "commandName" : " DebugRoslynComponent" ,
9+ "targetProject" : " ..\\ Sample\\ MinimalApi\\ MinimalApi.csproj"
610 }
711 }
812}
You can’t perform that action at this time.
0 commit comments