Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
63 changes: 29 additions & 34 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
<Project>
<Sdk Name="ViHo.PackAsAnalyzer" Version="1.0.1" />

<PropertyGroup>
<Nullable>enable</Nullable>
<Version>1.11.4-preview1</Version>
<SignAssembly>False</SignAssembly>
</PropertyGroup>

<PropertyGroup Label="Package Attributes">
<Authors>domn1995</Authors>
<Company />
<Description>A simple source generator for discriminated unions in C#.</Description>
<PackageProjectUrl>https://github.com/domn1995/dunet</PackageProjectUrl>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/domn1995/dunet</RepositoryUrl>
<PackageTags>source; generator; discriminated; union; functional; tagged;</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>https://github.com/domn1995/dunet/releases</PackageReleaseNotes>
<RepositoryType>git</RepositoryType>
<PackageIcon>favicon.png</PackageIcon>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<Target Name="DotnetToolRestore" BeforeTargets="Restore">
<Exec Command="dotnet tool restore" />
</Target>

<ItemGroup Condition=" '$(IsPackable)' == 'true' ">
<None Include="$(MSBuildThisFileDirectory)\Readme.md" Pack="true" PackagePath="\"/>
<None Include="$(MSBuildThisFileDirectory)\favicon.png" Pack="true" PackagePath="\"/>
</ItemGroup>
<Sdk Name="ViHo.PackAsAnalyzer" Version="1.0.1" />
<PropertyGroup>
<Nullable>enable</Nullable>
<Version>1.11.4-preview1</Version>
<SignAssembly>False</SignAssembly>
</PropertyGroup>
<PropertyGroup Label="Package Attributes">
<Authors>domn1995</Authors>
<Company />
<Description>A simple source generator for discriminated unions in C#.</Description>
<PackageProjectUrl>https://github.com/domn1995/dunet</PackageProjectUrl>
<PackageReadmeFile>Readme.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/domn1995/dunet</RepositoryUrl>
<PackageTags>source; generator; discriminated; union; functional; tagged;</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>https://github.com/domn1995/dunet/releases</PackageReleaseNotes>
<RepositoryType>git</RepositoryType>
<PackageIcon>favicon.png</PackageIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<Target Name="DotnetToolRestore" BeforeTargets="Restore">
<Exec Command="dotnet tool restore" />
</Target>
<ItemGroup Condition=" '$(IsPackable)' == 'true' ">
<None Include="$(MSBuildThisFileDirectory)\Readme.md" Pack="true" PackagePath="\" />
<None Include="$(MSBuildThisFileDirectory)\favicon.png" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
42 changes: 19 additions & 23 deletions benchmark/Dunet.Benchmark/Dunet.Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.15.4" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Dunet\Dunet.csproj" />
<ProjectReference Include="..\..\src\Dunet.Generator\Dunet.Generator.csproj" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.15.4" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.11.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Dunet\Dunet.csproj" />
<ProjectReference Include="..\..\src\Dunet.Generator\Dunet.Generator.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion benchmark/Dunet.Benchmark/SourceGeneratorBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private static CSharpCompilation CreateCompilation(params string[] sources) =>
),
MetadataReference.CreateFromFile(
typeof(UnionAttribute).GetTypeInfo().Assembly.Location
)
),
],
options: new CSharpCompilationOptions(OutputKind.ConsoleApplication)
);
Expand Down
43 changes: 20 additions & 23 deletions integration/Dunet.Integration.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
<PackageReference Include="FluentAssertions" Version="8.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
<PackageReference Include="FluentAssertions" Version="8.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
23 changes: 10 additions & 13 deletions samples/AreaCalculator/AreaCalculator.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
</ItemGroup>
</Project>
23 changes: 10 additions & 13 deletions samples/ExpressionCalculator/ExpressionCalculator.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
</ItemGroup>
</Project>
23 changes: 10 additions & 13 deletions samples/OptionMonad/OptionMonad.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
</ItemGroup>
</Project>
23 changes: 10 additions & 13 deletions samples/PokemonClient/PokemonClient.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
</ItemGroup>
</Project>
25 changes: 11 additions & 14 deletions samples/Serialization/Serialization.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
<PackageReference Include="System.Text.Json" Version="9.0.4" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dunet" Version="1.11.2" />
<PackageReference Include="System.Text.Json" Version="9.0.4" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private static StringBuilder AppendExtensionClassDeclaration(
UnionDeclaration union
) =>
builder.AppendLine(
$"{union.Accessibility.ToKeyword()} static class {union.Name}MatchExtensions"
$"{union.Accessibility.ToKeyword()} static class {union.Name}{union.TypeParameters.Count}MatchExtensions"
);

private static StringBuilder AppendUsingStatements(
Expand Down
6 changes: 2 additions & 4 deletions src/Dunet.Generator/UnionGeneration/UnionGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ private static void Emit(SourceProductionContext context, UnionDeclaration union

var union = UnionSourceBuilder.Build(unionRecord);
context.AddSource(
unionRecord.TypeParameters.Count == 0
? $"{unionRecord.Namespace}.{unionRecord.Name}.g.cs"
: $"{unionRecord.Namespace}.{unionRecord.Name}.{unionRecord.TypeParameters.Count}.g.cs",
$"{unionRecord.Namespace}.{unionRecord.Name}{unionRecord.TypeParameters.Count}.g.cs",
SourceText.From(union, Encoding.UTF8)
);

Expand All @@ -59,7 +57,7 @@ private static void Emit(SourceProductionContext context, UnionDeclaration union
{
var matchExtensions = UnionExtensionsSourceBuilder.GenerateExtensions(unionRecord);
context.AddSource(
$"{unionRecord.Namespace}.{unionRecord.Name}MatchExtensions.g.cs",
$"{unionRecord.Namespace}.{unionRecord.Name}{unionRecord.TypeParameters.Count}MatchExtensions.g.cs",
SourceText.From(matchExtensions, Encoding.UTF8)
);
}
Expand Down
Loading