Skip to content

Switch lock backport package to #if defs instead#3217

Merged
Misha-133 merged 1 commit into
discord-net:devfrom
SquirrelKiev:net9locking
Dec 31, 2025
Merged

Switch lock backport package to #if defs instead#3217
Misha-133 merged 1 commit into
discord-net:devfrom
SquirrelKiev:net9locking

Conversation

@SquirrelKiev

Copy link
Copy Markdown
Contributor

The addition of a new package and the details surrounding that new package somewhat irks me, so this PR removes said new package and replaces it with some simple #if NET9_0_OR_GREATERs. Should accomplish the same thing but without adding new stuff to the csproj.

@MarkCiliaVincenti

Copy link
Copy Markdown
Contributor

The package is set to run in source generator mode, which means that it won't actually add a dependency.

@SquirrelKiev

SquirrelKiev commented Dec 30, 2025

Copy link
Copy Markdown
Contributor Author

Not formally no but from what I can tell it just copies the runtime package into the source of the project.
But even if that's fine, the whole point of the package is to provide the APIs that lock provides to <NET 9, but we're not even using those - the entire package can be replaced with some #if NET9_0_OR_GREATERs with no consequence or extra build dependencies. This feels like the package was just added for the sake of adding the package.

@MarkCiliaVincenti

Copy link
Copy Markdown
Contributor

Right, but those directives are both an eyesore and limiting in scope. Yes, currently only the lock keyword is used but the polyfill allows for using the whole API.

For starters, using the preprocessor directives won't allow you to lock with a timeout, or you'd have to use preprocessor directives on the timeout lock call too.

@Misha-133 Misha-133 merged commit b386a0e into discord-net:dev Dec 31, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants