generated from codebeltnet/dotnet-new-classlib
-
Notifications
You must be signed in to change notification settings - Fork 1
Switched to the more performant System.Threading.Lock on .NET 9.0+ #18
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 48 additions & 41 deletions
89
src/Codebelt.Extensions.Xunit.Hosting/Codebelt.Extensions.Xunit.Hosting.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,52 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <ProjectGuid>1e0bdf91-e7c7-4cb4-a39d-e1a5374c5602</ProjectGuid> | ||
| <SonarQubeTestProject>false</SonarQubeTestProject> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <Description>The Codebelt.Extensions.Xunit.Hosting namespace contains types that provides a uniform way of doing unit testing used in conjunction with Microsoft Dependency Injection. The namespace relates to the Xunit.Abstractions namespace.</Description> | ||
| <PackageTags>host-test class-fixture host-fixture microsoft dependency injection host configuration hosting-environment service-provider configure-services</PackageTags> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup Condition="$(TargetFramework.StartsWith('net9'))"> | ||
| <PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-rc.2.24473.5" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0-rc.2.24473.5" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0-rc.2.24473.5" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.0-rc.2.24473.5" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0-rc.2.24473.5" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="$(TargetFramework.StartsWith('net8'))"> | ||
| <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="$(TargetFramework.StartsWith('netstandard2'))"> | ||
| <PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="xunit.extensibility.core" Version="2.9.2" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Codebelt.Extensions.Xunit\Codebelt.Extensions.Xunit.csproj" /> | ||
| </ItemGroup> | ||
| <PropertyGroup> | ||
| <ProjectGuid>1e0bdf91-e7c7-4cb4-a39d-e1a5374c5602</ProjectGuid> | ||
| <SonarQubeTestProject>false</SonarQubeTestProject> | ||
| </PropertyGroup> | ||
|
|
||
| <PropertyGroup> | ||
| <Description>The Codebelt.Extensions.Xunit.Hosting namespace contains types that provides a uniform way of doing unit testing used in conjunction with Microsoft Dependency Injection. The namespace relates to the Xunit.Abstractions namespace.</Description> | ||
| <PackageTags>host-test class-fixture host-fixture microsoft dependency injection host configuration hosting-environment service-provider configure-services</PackageTags> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup Condition="$(TargetFramework.StartsWith('net9'))"> | ||
| <PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-rc.2.24473.5" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0-rc.2.24473.5" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0-rc.2.24473.5" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.0-rc.2.24473.5" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0-rc.2.24473.5" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="$(TargetFramework.StartsWith('net8'))"> | ||
| <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="$(TargetFramework.StartsWith('netstandard2'))"> | ||
| <PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.1.1" /> | ||
| <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Cuemon.Extensions.Threading" Version="9.0.0-preview.11" /> | ||
| <PackageReference Include="xunit.extensibility.core" Version="2.9.2" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Using Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))" Alias="Lock" Include="System.Threading.Lock" /> | ||
| <Using Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net9.0'))" Alias="Lock" Include="Backport.System.Threading.Lock" /> | ||
| <Using Alias="LockFactory" Include="Backport.System.Threading.LockFactory" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Codebelt.Extensions.Xunit\Codebelt.Extensions.Xunit.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Conditional compilation missing for
Lockinitialization.The
_lockfield is initialized withLockFactory.Create()without being enclosed in a#if NET9_0_OR_GREATERdirective. This change affects all target frameworks, potentially causing compatibility issues for projects not targeting .NET 9.0 or higher.Enclose the
Lockinitialization within conditional compilation directives:Verify that the
Disposemethod and any other usages of_lockare appropriately handled for both cases.Update the class documentation to reflect the conditional use of
Lockbased on the .NET version.🔗 Analysis chain
LGTM! Consider adding conditional compilation and updating documentation.
The change to use
Lockinstead ofobjectfor the_lockfield aligns with the PR objective of switching to a more performantSystem.Threading.Lockon .NET 9.0+. This is likely to improve performance and provide more advanced locking capabilities.To ensure this change is only applied for .NET 9.0 and above, consider wrapping it in a conditional compilation directive:
Also, update the class documentation to mention this optimization for .NET 9.0+.
To verify the usage of
System.Threading.Lock, run the following script:🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 237
Script:
Length of output: 222
Script:
Length of output: 565