Skip unnecessary BCL package reference if targeting .NET 6 or later#857
Merged
jbogard merged 1 commit intoLuckyPennySoftware:masterfrom Feb 23, 2023
Merged
Conversation
Contributor
Author
|
😕Seems like there is a flaky test that relies on timing ( |
jbogard
reviewed
Feb 23, 2023
Collaborator
jbogard
left a comment
There was a problem hiding this comment.
Were the additional null checks a side effect of .NET 6?
Contributor
Author
Yes. Basically it adds more precise hints on the existing runtime behavior. I think it's a positive thing, it puts in evidence paths that could eventually throw a null-reference exception. |
jbogard
approved these changes
Feb 23, 2023
This was referenced Sep 28, 2025
This was referenced Oct 27, 2025
This was referenced Nov 10, 2025
This was referenced Dec 1, 2025
This was referenced Dec 16, 2025
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
As mentioned in #852, I would like to introduce multi-targeting only to skip an unnecessary package reference (
Microsoft.Bcl.AsyncInterfaces) on .NET 6 and later, because it's already included by default.A (positive?) side effect of targeting
net6.0is that a few warnings appeared in existing code because of new nullable reference types annotations. For instance,IServiceProvider.GetService(Type serviceType):objectinnetstandard2.0object?innet6.0At runtime, the behavior is the same. It's just that Microsoft added more hints to prevent null reference exceptions. I had to fix these warnings, and that explains the number of changes.
While fixing these warnings in
Mediator.cs, I also added:InvalidOperationExceptionif we can't create the wrapper for stream requests handlers (instead of null-ref ex),InvalidOperationExceptionmessages