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
7 changes: 2 additions & 5 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@ name: .NET

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
dotnet-version: 9.0.x
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating to .NET 9.0.x may introduce compatibility issues since your knowledge cutoff is January 2025 and it's now June 2025. Consider verifying that all dependencies and target frameworks are compatible with .NET 9.0.

Suggested change
dotnet-version: 9.0.x
dotnet-version: 9.0.x
- name: Verify compatibility
run: dotnet list package --outdated

Copilot uses AI. Check for mistakes.
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
run: dotnet test --no-build --verbosity detailed
8 changes: 5 additions & 3 deletions Build.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cd /d "%~dp0"
"%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" Linq.Expressions.Deconstruct.sln /p:Configuration=Release /t:Restore;Rebuild /v:m
"%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" Linq.Expressions.Deconstruct.sln /p:Configuration=Debug /t:Restore;Rebuild /v:m
cd /d "%~dp0"
Copy link

Copilot AI Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The build script retains the old MSBuild approach in comments but doesn't remove them. Consider removing the commented lines to avoid confusion about which build approach to use.

Copilot uses AI. Check for mistakes.
dotnet restore
dotnet build --no-restore
dotnet test --no-build --verbosity normal

15 changes: 15 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PolySharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
11 changes: 11 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project>
<ItemGroup>
<PackageVersion Include="PolySharp" Version="1.15.0" />
<PackageVersion Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageVersion Include="NUnit" Version="4.3.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="4.14.0" />
</ItemGroup>
</Project>
53 changes: 0 additions & 53 deletions Linq.Expressions.Deconstruct.sln

This file was deleted.

16 changes: 16 additions & 0 deletions Linq.Expressions.Deconstruct.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Solution>
<Folder Name="/.github/" />
<Folder Name="/.github/workflows/">
<File Path=".github/workflows/dotnet.yml" />
</Folder>
<Folder Name="/.root/">
<File Path="Build.cmd" />
<File Path="Directory.Build.props" />
<File Path="Directory.Packages.props" />
<File Path="LICENSE.TXT" />
<File Path="README.md" />
</Folder>
<Project Path="Source/Linq.Expressions.Deconstruct.csproj" />
<Project Path="SourceGenerators/SourceGenerators.csproj" />
<Project Path="Tests/Linq.Expressions.Deconstruct.Tests.csproj" />
</Solution>
22 changes: 11 additions & 11 deletions Source/Expr.tt
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ namespace Linq.Expressions.Deconstruct

foreach (var item in new []
{
"Add", "AddChecked", "And", "AndAlso", "ArrayIndex",
"Assign", "Coalesce", "Divide", "Equal", "ExclusiveOr",
"GreaterThan", "GreaterThanOrEqual", "LeftShift", "LessThan", "LessThanOrEqual",
"Modulo", "Multiply", "MultiplyChecked", "NotEqual", "Or",
"OrElse", "Power", "RightShift", "Subtract", "SubtractChecked",
"AddAssign", "AndAssign", "DivideAssign", "ExclusiveOrAssign", "LeftShiftAssign",
"ModuloAssign", "MultiplyAssign", "OrAssign", "PowerAssign", "RightShiftAssign",
"SubtractAssign", "AddAssignChecked", "MultiplyAssignChecked", "SubtractAssignChecked",
"Add", "AddChecked", "And", "AndAlso", "ArrayIndex",
"Assign", "Coalesce", "Divide", "Equal", "ExclusiveOr",
"GreaterThan", "GreaterThanOrEqual", "LeftShift", "LessThan", "LessThanOrEqual",
"Modulo", "Multiply", "MultiplyChecked", "NotEqual", "Or",
"OrElse", "Power", "RightShift", "Subtract", "SubtractChecked",
"AddAssign", "AndAssign", "DivideAssign", "ExclusiveOrAssign", "LeftShiftAssign",
"ModuloAssign", "MultiplyAssign", "OrAssign", "PowerAssign", "RightShiftAssign",
"SubtractAssign", "AddAssignChecked", "MultiplyAssignChecked", "SubtractAssignChecked",
})
{
#>
Expand Down Expand Up @@ -148,9 +148,9 @@ namespace Linq.Expressions.Deconstruct

foreach (var item in new []
{
"ArrayLength", "Convert", "ConvertChecked", "Negate", "NegateChecked",
"Not", "Quote", "TypeAs", "UnaryPlus", "Decrement",
"Increment", "IsFalse", "IsTrue", "Throw", "Unbox",
"ArrayLength", "Convert", "ConvertChecked", "Negate", "NegateChecked",
"Not", "Quote", "TypeAs", "UnaryPlus", "Decrement",
"Increment", "IsFalse", "IsTrue", "Throw", "Unbox",
"PreIncrementAssign", "PreDecrementAssign", "PostIncrementAssign", "PostDecrementAssign", "OnesComplement",
})
{
Expand Down
7 changes: 0 additions & 7 deletions Source/Linq.Expressions.Deconstruct.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Linq.Expressions.Deconstruct.snk</AssemblyOriginatorKeyFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
Expand All @@ -30,11 +28,6 @@

<ProjectReference Include="..\SourceGenerators\SourceGenerators.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />

<PackageReference Include="PolySharp" Version="1.15.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

<Compile Update="Expr.generated.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand Down
11 changes: 3 additions & 8 deletions SourceGenerators/SourceGenerators.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,11 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<LangVersion>preview</LangVersion>
</PropertyGroup>

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

</Project>
6 changes: 3 additions & 3 deletions SourceGenerators/ToExprGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ sealed class ToExprAttribute : Attribute

foreach (var group in grouped)
{
var classSource = ProcessClass((INamedTypeSymbol)group.Key, group.ToList(), spc);
spc.AddSource($"{group.Key.Name}.ToExpr.g.cs", SourceText.From(classSource, Encoding.UTF8));
var classSource = ProcessClass((INamedTypeSymbol)group.Key!, group.ToList(), spc);
spc.AddSource($"{group.Key!.Name}.ToExpr.g.cs", SourceText.From(classSource, Encoding.UTF8));
}
});
}

static IFieldSymbol GetFieldSymbolWithAttribute(GeneratorSyntaxContext context)
static IFieldSymbol? GetFieldSymbolWithAttribute(GeneratorSyntaxContext context)
{
if (context.Node is not FieldDeclarationSyntax fieldDeclaration)
return null;
Expand Down
18 changes: 6 additions & 12 deletions Tests/Linq.Expressions.Deconstruct.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
<TargetFrameworks>net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="PolySharp" Version="1.15.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Appveyor.TestLogger" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="NUnit" />

<ProjectReference Include="..\Source\Linq.Expressions.Deconstruct.csproj" />
</ItemGroup>

</Project>
</Project>
30 changes: 15 additions & 15 deletions Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,21 +263,21 @@ static Expr Add(Expr ex, object xv, object yv)

var f1 = f.TransformEx(ex => ex switch
{
Multiply(Constant(_, 0) e, _) => e, // 0 * e => 0
Multiply(_, Constant(_, 0) e) => e, // e * 0 => 0
Multiply(Constant(_, 1), var e) => e, // 1 * e => e
Multiply(var e, Constant(_, 1)) => e, // e * 1 => e
Divide (_, Constant(_, 0)) => ex,
Divide (Constant(_, 0) e, _) => e, // 0 / e => 0
Divide (var e, Constant(_, 1)) => e, // e / 1 => e
Add (Constant(_, 0), var e) => e, // 0 + e => e
Add (var e, Constant(_, 0)) => e, // e + 0 => e
Subtract(Constant(_, 0), var e) => Ex.Negate(e), // 0 - e => -e
Subtract(var e, Constant(_, 0)) => e, // e - 0 => e
Multiply(Constant(long x), Constant(long y)) => Ex.Constant(x * y), // x * y => e
Divide (Constant(long x), Constant(long y)) => Ex.Constant(x / y), // x / y => e
Add (Constant(var x), Constant(var y)) => Add(ex, x, y), // x + y => e
Subtract(Constant(long x), Constant(long y)) => Ex.Constant(x - y), // x - y => e
Multiply(Constant(_, 0) e, _) => e, // 0 * e => 0
Multiply(_, Constant(_, 0) e) => e, // e * 0 => 0
Multiply(Constant(_, 1), var e) => e, // 1 * e => e
Multiply(var e, Constant(_, 1)) => e, // e * 1 => e
Divide (_, Constant(_, 0)) => ex,
Divide (Constant(_, 0) e, _) => e, // 0 / e => 0
Divide (var e, Constant(_, 1)) => e, // e / 1 => e
Add (Constant(_, 0), var e) => e, // 0 + e => e
Add (var e, Constant(_, 0)) => e, // e + 0 => e
Subtract(Constant(_, 0), var e) => Ex.Negate(e), // 0 - e => -e
Subtract(var e, Constant(_, 0)) => e, // e - 0 => e
Multiply(Constant(long x), Constant(long y)) => Ex.Constant(x * y), // x * y => e
Divide (Constant(long x), Constant(long y)) => Ex.Constant(x / y), // x / y => e
Add (Constant(var x), Constant(var y)) => Add(ex, x, y), // x + y => e
Subtract(Constant(long x), Constant(long y)) => Ex.Constant(x - y), // x - y => e
_ => ex
});

Expand Down