Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added .NET 8 target #696

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

Conversation

multiarc
Copy link

@multiarc multiarc commented Jan 12, 2025

  1. Added .NET 8 Support

    • Aligned package versions with respective targets (.NET 6, netstandard2.0, .NET 8.0)
    • Removed .NET 7.0 target and outdated references
    • Removed direct targets on the library for .NET Framework and only left netstandard2.0 because of dependencies, netstandard2.0 reference required anyways and there is no point to split targets on the library itself.
  2. StyleCop is deprecated

    • Removed StyleCop.Analyzers in favor of Microsoft.CodeAnalysis.NetAnalyzers (debatable, but feels appropriate in this case)
    • Fixed nullable references issues and other minor issues
  3. Moved packages for unit tests out of .props file

  4. Upgraded xUnit

    • Fixed xUnit warnings
  5. Upgraded the rest of packages in unit tests

  6. Added packages packages.lock.json for repeatable restore

1.1 Aligned package versions with respective targets (.NET 6, netstandard2.0, .NET 8.0)
1.2 Removed .NET 7.0 target
1.3 Removed direct targets on the library for .NET Framework and only left netstandard2.0 because of dependencies, netstandard2.0 reference required anyways and there is no point to split targets on the library itself.
2. StyleCop is deprecated
2.1 Removed StyleCop
2.2 Added Microsoft.CodeAnalysis.NetAnalyzers
2.3 Fixed nullable references issues and other minor issues
3. Moved packages for unit tests out of .props file
4. Upgraded xUnit
4.1 Fixed xUnit warnings
5. Upgraded the rest of packages in unit tests

Signed-off-by: Aliaksandr Kukrash <[email protected]>
@github-actions github-actions bot added enhancement Issues describing an enhancement or pull requests adding an enhancement. maintenance Pull requests that perform maintenance on the project but add no features or bug fixes. labels Jan 12, 2025
…ect settings to .props file

Signed-off-by: Aliaksandr Kukrash <[email protected]>
@multiarc multiarc marked this pull request as ready for review January 12, 2025 00:42
Signed-off-by: Aliaksandr Kukrash <[email protected]>
… latest .NET version in dotnet-install.sh

Signed-off-by: Aliaksandr Kukrash <[email protected]>
Copy link
Collaborator

@Turnerj Turnerj left a comment

Choose a reason for hiding this comment

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

Hey - appreciate the effort you went to with this PR. I've added some comments.

inputs:
packageType: "sdk"
useGlobalJson: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

What made you want to switch from the global.json being used to specifying the .NET 8 SDK manually? Just consistency with the others?

Copy link
Author

Choose a reason for hiding this comment

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

Ideally, you would use latest available patch when building project as opposed to whatever is laying around in your global.json, unless there is a compatibility issue. This was the reason of removal

<TargetPathWithTargetPlatformMoniker Include="$(PKGSystem_Threading_Tasks_Extensions)\lib\netstandard2.0\*.dll" IncludeRuntimeDependency="false" />
</ItemGroup>
</Target>
<!-- <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">-->
Copy link
Collaborator

Choose a reason for hiding this comment

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

This whole section was to work around transitive dependency issues with source generators (basically if your dependencies have dependencies, you need to specify them all for source generators). Did you not have issues with this with the code compiling?

I guess my only thought is the lock files may help resolve this but I haven't seen anyone mention that on the discussions on GitHub about source generators before.

Copy link
Author

Choose a reason for hiding this comment

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

Do you have repro steps for this? I will check and add some tests as well to cover this case.

@@ -1,62 +1,42 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Label="Build">
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;netstandard2.0</TargetFrameworks>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Source generators can only target netstandard2.0 unfortunately.

Copy link
Author

Choose a reason for hiding this comment

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

This one is interesting. Purely speaking you can use any target for source generator: after all this is just Roslyn, you have all targets available. But! It only works in console (dotnet command line) and in Rider IDE. Visual Studio and MSBuild cannot do that properly and spawns all sorts of issues (missing references, not able to compile, etc.)
image
As opposed to command line (view from Rider):
image

Copy link
Author

Choose a reason for hiding this comment

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

I can even remove netstandard2.0 completely from the targets and it continues to function no problem.

Copy link
Author

Choose a reason for hiding this comment

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

I will look into it.

Copy link
Author

@multiarc multiarc Jan 14, 2025

Choose a reason for hiding this comment

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

I split Tool project into separate projects to allow proper package versioning for different targets when built from console (and published as a package) - as you cannot properly reference different versions of System.Text.Json and others from within single target. While allowing usage from Visual Studio and falling back to netstandard2.0 only.

@@ -1,13 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup Label="Build">
<TargetFrameworks>net7.0;net6.0;net472</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;net462;net472;net48</TargetFrameworks>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure how necessary it is to test 3 different versions of .NET Framework. I'd personally be happy to just test one .NET Framework version (likely 4.8).

Copy link
Author

@multiarc multiarc Jan 14, 2025

Choose a reason for hiding this comment

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

I don't see a harm of listing major relevant versions in here. Benchmarks is another story and probably it worth removing. But I agree, generally speaking it shouldn't matter.

Copy link
Author

Choose a reason for hiding this comment

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

Please let me know how to proceed here. Keep all net versions or leave net48 only?

.github/workflows/build.yml Outdated Show resolved Hide resolved
@multiarc multiarc marked this pull request as draft January 14, 2025 21:20
…other IDEs and dotnet command line.

Signed-off-by: Aliaksandr Kukrash <[email protected]>
Signed-off-by: Aliaksandr Kukrash <[email protected]>
@multiarc multiarc force-pushed the feature/net8_support branch from 34e1c81 to e9214e5 Compare January 14, 2025 21:59
Signed-off-by: Aliaksandr Kukrash <[email protected]>
Signed-off-by: Aliaksandr Kukrash <[email protected]>
@multiarc multiarc requested a review from Turnerj January 14, 2025 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issues describing an enhancement or pull requests adding an enhancement. maintenance Pull requests that perform maintenance on the project but add no features or bug fixes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants