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

Add ObjectDisposedException.Throw for object instance and type #58684

Merged
merged 21 commits into from
Oct 25, 2021

Conversation

Bibletoon
Copy link
Contributor

Closes #51700
I've decided to make static methods instead of new ctors because of breaking changes with null argument (like there and there)

Should I also change old calls like that throw new ObjectDisposedException(GetType().FullName); or throw new ObjectDisposedException(GetType().Name); to new method?

@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@dnfadmin
Copy link

dnfadmin commented Sep 4, 2021

CLA assistant check
All CLA requirements met.

@marek-safar
Copy link
Contributor

Should I also change old calls like that throw new ObjectDisposedException(GetType().FullName); or throw new ObjectDisposedException(GetType().Name); to new method?

Yes please but in separate PR.

@stephentoub
Copy link
Member

I've decided to make static methods instead of new ctors because of breaking changes with null argument (like there and there)

The APIs were approved as constructors. We can't merge this with different APIs unless that's officially revisited (my comment about using static members instead was just a musing).
cc: @terrajobst, @bartonjs

@stephentoub
Copy link
Member

Should I also change old calls like that throw new ObjectDisposedException(GetType().FullName); or throw new ObjectDisposedException(GetType().Name); to new method?

Yes please but in separate PR.

FWIW, my preference is actually to do it in the same PR. That helps to validate the design of the API by seeing whether there are any places we'd like to change that can't be changed for some reason, or otherwise discovering issues with the shape of the API. That's still possible if it's rolled out separately, but only after it's already been merged, at which point we then need to go back and revise the public API, which could have already been adopted elsewhere up-stack by that point, and now we need to deal with a breaking change (within the same release).

@stephentoub
Copy link
Member

I've decided to make static methods instead of new ctors because of breaking changes with null argument (like there and there)

I don't think these arguments should be nullable (it's also not what was approved in the API review). Allowing these to be null is promoting poor usage, and the cases you highlighted are good examples of how those exceptions are lacking appropriate details for debugging because null was passed in. We wouldn't consider it breaking to pass in this instead of null for those two examples.

@tmds
Copy link
Member

tmds commented Sep 8, 2021

Maybe also add?

public static void Throw<T>() => Throw(typeof(T));

@bartonjs
Copy link
Member

I've reset the issue to api-ready-for-review to discuss the implementation-vs-spec mismatch.

@bartonjs bartonjs added the blocked Issue/PR is blocked on something - see comments label Sep 17, 2021
@bartonjs bartonjs removed the blocked Issue/PR is blocked on something - see comments label Sep 24, 2021
@bartonjs
Copy link
Member

LGTM, but I defer to @stephentoub in case he has last minute second thoughts 😄

@ghost
Copy link

ghost commented Oct 21, 2021

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Issue Details

Closes #51700
I've decided to make static methods instead of new ctors because of breaking changes with null argument (like there and there)

Should I also change old calls like that throw new ObjectDisposedException(GetType().FullName); or throw new ObjectDisposedException(GetType().Name); to new method?

Author: Bibletoon
Assignees: -
Labels:

area-System.Runtime, new-api-needs-documentation

Milestone: -

Copy link
Member

@jeffhandley jeffhandley left a comment

Choose a reason for hiding this comment

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

There are a couple of formatting tweaks needed; otherwise this looks good. I've queued up suggestions for those formatting tweaks; I'll go ahead and commit them.

The test failure is #47968.

@jeffhandley
Copy link
Member

The other failure is #60706, which has been fixed in main already.

@jeffhandley jeffhandley merged commit 9e795c0 into dotnet:main Oct 25, 2021
@jeffhandley
Copy link
Member

Thank you for the contribution, @Bibletoon! Nice work and thanks for iterating through the feedback.

@EgorBo
Copy link
Member

EgorBo commented Nov 2, 2021

Improvements on ubuntu x64 dotnet/perf-autofiling-issues#2086

@stephentoub
Copy link
Member

Improvements on ubuntu x64

Why/how would this change have impacted that particular benchmark?

@EgorBo
Copy link
Member

EgorBo commented Nov 2, 2021

Improvements on ubuntu x64

Why/how would this change have impacted that particular benchmark?

this commit was the only suspect in improvements of that benchmark
image

but most likely it's just a noise. I assumed ThrowHelpers helped some IPAddress-related functions to become inlining-friendly

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add new ObjectDisposedException constructor overload