Skip to content

Commit

Permalink
Fixed code generation for generic unions where some type parameters c…
Browse files Browse the repository at this point in the history
…ontained constraints yielded invalid code.

=> release
  • Loading branch information
hugener committed Dec 13, 2023
1 parent 5ec0b76 commit 8cb77ca
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
2 changes: 1 addition & 1 deletion Source/Sundew.Base
Submodule Sundew.Base updated 100 files
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Sundew.DiscriminatedUnions.Generator.OutputStage;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using Sundew.Base.Collections.Immutable;
using Sundew.Base.Text;
Expand Down Expand Up @@ -176,19 +177,18 @@ public static StringBuilder TryAppendConstraints(this StringBuilder stringBuilde
typeParameters,
(builder, parameter) =>
{
builder
.Append(indentation)
.Append(Where)
.Append(' ')
.Append(parameter.Name)
.Append(' ')
.Append(':')
.Append(' ');
stringBuilder.AppendItems(
parameter.Constraints,
(builder1, constraint) => builder1.Append(constraint),
ListSeparator)
.AppendLine();
builder.If(
!parameter.Constraints.IsEmpty,
builder1 => builder1.Append(indentation)
.Append(Where)
.Append(' ')
.Append(parameter.Name)
.Append(' ').Append(':').Append(' ')
.AppendItems(
parameter.Constraints,
(builder1, constraint) => builder1.Append(constraint),
ListSeparator)
.AppendLine());
},
string.Empty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

<SundewBaseEqualityCompile Include="..\Sundew.Base\Source\Sundew.Base.Equality\Equality.cs" />
<Compile Include="@(SundewBaseEqualityCompile)" LinkBase="Shared\Sundew.Base.Equality" />
<SundewBasePrimitivesCompile Include="..\Sundew.Base\Source\Sundew.Base.Primitives\Computation\R*.cs" />
<SundewBasePrimitivesCompile Include="..\Sundew.Base\Source\Sundew.Base.Primitives\Computation\O.cs" />
<SundewBasePrimitivesCompile Include="..\Sundew.Base\Source\Sundew.Base.Primitives\R*.cs" />
<SundewBasePrimitivesCompile Include="..\Sundew.Base\Source\Sundew.Base.Primitives\O.cs" />
<SundewBasePrimitivesCompile Include="..\Sundew.Base\Source\Sundew.Base.Primitives\EnumExtensions.cs" />
<Compile Include="@(SundewBasePrimitivesCompile)" LinkBase="Shared\Sundew.Base.Primitives" />
<SundewBaseCollectionsCompile Include="..\Sundew.Base\Source\Sundew.Base.Collections\Immutable\ValueArray{TItem}.cs" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace Sundew.DiscriminatedUnions.Generator.IntegrationTests;
using System.IO;
using System.Linq;
using FluentAssertions;
using NUnit.Framework;
using Sundew.Testing.CodeAnalysis;
using Sundew.Testing.IO;
using Xunit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,18 @@ public static StringBuilder TryAppendConstraints(this StringBuilder stringBuilde
typeParameters,
(builder, parameter) =>
{
builder
.Append(indentation)
.Append(Where)
.Append(' ')
.Append(parameter.Name)
.Append(' ')
.Append(':')
.Append(' ');
stringBuilder.AppendItems(
parameter.Constraints,
(builder1, constraint) => builder1.Append(constraint),
ListSeparator)
.AppendLine();
builder.If(
!parameter.Constraints.IsEmpty,
builder1 => builder1.Append(indentation)
.Append(Where)
.Append(' ')
.Append(parameter.Name)
.Append(' ').Append(':').Append(' ')
.AppendItems(
parameter.Constraints,
(builder1, constraint) => builder1.Append(constraint),
ListSeparator)
.AppendLine());
},
string.Empty);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

<SundewBaseEqualityCompile Include="..\Sundew.Base\Source\Sundew.Base.Equality\Equality.cs" />
<Compile Include="@(SundewBaseEqualityCompile)" LinkBase="Shared\Sundew.Base.Equality" />
<SundewBasePrimitivesCompile Include="..\Sundew.Base\Source\Sundew.Base.Primitives\Computation\R*.cs" />
<SundewBasePrimitivesCompile Include="..\Sundew.Base\Source\Sundew.Base.Primitives\Computation\O.cs" />
<SundewBasePrimitivesCompile Include="..\Sundew.Base\Source\Sundew.Base.Primitives\R*.cs" />
<SundewBasePrimitivesCompile Include="..\Sundew.Base\Source\Sundew.Base.Primitives\O.cs" />
<SundewBasePrimitivesCompile Include="..\Sundew.Base\Source\Sundew.Base.Primitives\EnumExtensions.cs" />
<Compile Include="@(SundewBasePrimitivesCompile)" LinkBase="Shared\Sundew.Base.Primitives" />
<SundewBaseCollectionsCompile Include="..\Sundew.Base\Source\Sundew.Base.Collections\Immutable\ValueArray{TItem}.cs" />
Expand Down

0 comments on commit 8cb77ca

Please sign in to comment.