Releases: domn1995/dunet
v1.15.0
What's Changed
- Binary
orpatterns are now also checked for exhaustiveness. For example:
[Union]
partial record Shape
{
partial record Circle(double Radius);
partial record Rectangle(double Length, double Width);
partial record Square(double Length);
partial record Triangle(double Base, double Height);
}
Shape? shape = null;
var sides = shape switch
{
// This is now considered as handling both the `Circle` and `null` cases.
Circle or null => 0,
// This is now considered as handling both the `Rectangle` and `Square` cases.
Rectangle or Square => 4,
Triangle t => 3,
};Package
https://www.nuget.org/packages/Dunet/1.15.0
Full Changelog
v1.14.0
What's Changed
- Some property patterns are now also checked for exhaustiveness. For example:
[Union]
partial record Shape
{
partial record Circle(double Radius);
partial record Rectangle(double Length, double Width);
partial record Triangle(double Base, double Height);
}
Shape shape = new Circle(3.14);
var area = shape switch
{
// This is now considered as handling the `Rectangle` case.
Rectangle { Length: var length, Width: var width } => length * width,
Circle(var radius) => 3.14 * radius * radius,
Triangle t => t.Base * t.Height / 2,
};
var area2 = shape switch
{
// This is now considered as handling the `Rectangle` case.
Rectangle { Length: _, Width: _ } => 0,
Circle(var radius) => 3.14 * radius * radius,
Triangle t => t.Base * t.Height / 2,
};Packages
https://www.nuget.org/packages/Dunet/1.14.0
Full Changelog
v1.13.1
What's Changed
- Fixed an issue where subsequent switch expressions in the same file were not being properly checked for exhaustiveness by @domn1995 in #364
Packages
https://www.nuget.org/packages/Dunet/1.13.1
Full Changelog
v1.13.0
What's Changed
Switch expressions on union types are now checked for exhaustiveness. For example:
using Dunet;
using static Option<int>;
[Union]
partial record Option<T>
{
partial record Some(T Value);
partial record None;
}
Option<int> option = new Some(42);
// Does not emit an exhaustiveness warning since all union variants are handled.
var message = option switch
{
Some(var value) => $"The value is {value}!",
None => "There's no value.",
};
// Emits an exhaustiveness warning because Some variant with Value != 5 is unhandled.
var message2 = option switch
{
Some(5) => "Value is 5!",
None => "There's no value.",
}This largely makes the .Match() method unnecessary and a future version of the package may mark it as obsolete.
Packages
https://www.nuget.org/packages/Dunet/1.13.0
Full Changelog
v1.12.0
What's Changed
[Union]
public partial record Option<T>
{
// An implicit conversion from `T` to `Some` is now generated.
public partial record Some(T Value);
public partial record None;
}Packages
https://www.nuget.org/packages/Dunet/1.12.0
Full Changelog
v1.11.4
What's Changed
- Fixes compilation issues on generated union types when there are 2 generic union types with the same name by @Dixin in #334
- Fixes compilation issues on generated extension methods when there are 2 generic union types with the same name by @domn1995 in #340
- Downgrades
Microsoft.CodeAnalysis.CSharpdependency to v4.11.0 to fix compilation issues by @domn1995 in #337
Packages
https://www.nuget.org/packages/Dunet/1.11.4
Full Changelog
New Contributors
v1.11.3
What's Changed
- Fixes namespace conflicts with System by @IchiganCS in #301
Packages
https://www.nuget.org/packages/Dunet/1.11.3
Full Changelog
v1.11.2
v1.11.1
What's Changed
- Mark generated source code as autogenerated by @hwoodiwiss in #215
Packages
https://www.nuget.org/packages/Dunet/1.11.1
Full Changelog
v1.11.0
What's Changed
- Bump Microsoft.CodeAnalysis.CSharp from 4.7.0 to 4.8.0 by @dependabot in #190
- Upgrade to dotnet 8 by @domn1995 in #187
- Bump PolySharp from 1.13.2 to 1.14.0 by @dependabot in #192
- Bump PolySharp from 1.14.0 to 1.14.1 by @dependabot in #201
- Separate UnionAttribute into its own project by @hwoodiwiss in #204
Migrating to v1.11.0
The following dunet package reference in .csproj files will now fail to build:
<PackageReference Include="dunet" Version="1.11.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>When upgrading to v1.11.0, you will need to simplify it to this:
<PackageReference Include="dunet" Version="1.11.0" />Packages
https://www.nuget.org/packages/Dunet/1.11.0
New Contributors
- @hwoodiwiss made their first contribution in #204