-
Notifications
You must be signed in to change notification settings - Fork 790
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
remove unreachable ?? new ConsoleExporterOptions() in ConsoleExporter #6079
base: main
Are you sure you want to change the base?
remove unreachable ?? new ConsoleExporterOptions() in ConsoleExporter #6079
Conversation
…s()-in-ConsoleExporter
…s()-in-ConsoleExporter
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6079 +/- ##
==========================================
- Coverage 86.40% 86.40% -0.01%
==========================================
Files 257 257
Lines 11649 11648 -1
==========================================
- Hits 10065 10064 -1
Misses 1584 1584
|
…s()-in-ConsoleExporter
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.
I am fine with this change, but there is one comment to this.
Historically, this project was released without Nullability check. When introduced, this kind of checks stays in place to avoid any hidden breaking changes. What is more, it is still possible to pass null here by null forgiving operator !
/disabling nullability in the project. IMO the problem is similar to the Debug.Assert discussed in #6101
@@ -10,7 +10,7 @@ public abstract class ConsoleExporter<T> : BaseExporter<T> | |||
|
|||
protected ConsoleExporter(ConsoleExporterOptions options) | |||
{ | |||
this.options = options ?? new ConsoleExporterOptions(); | |||
this.options = options; |
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.
I don't think this is the correct direction.
This is a public API. We can't control what users will pass it. Even though we say it shouldn't be null
(via the nullable annotations), it is still possible for users to pass null
.
It probably should have been written like this:
protected ConsoleExporter(ConsoleExporterOptions options)
{
Guard.ThrowIfNull(options);
this.options = options;
}
But technically a breaking change to do now.
If we really want to clean up the oddity, why not just embrace the fact that it allows null
?
- protected ConsoleExporter(ConsoleExporterOptions options)
+ protected ConsoleExporter(ConsoleExporterOptions? options)
{
this.options = options ?? new ConsoleExporterOptions();
Fixes #
Design discussion issue #
Changes
since it cant be null
Merge requirement checklist
CHANGELOG.md
files updated for non-trivial changes