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

[API Implementation]: Expose CookieException constructors #109026

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

deeprobin
Copy link
Contributor

This PR implements and fixes #95965.

  • Expose constructors
  • Add doc comments
  • Add new public API to ref assembly
  • Add tests for passing null and non-null parameters to the ctors

Potentially breaking change if somebody does reflection hacks:

  • Rename the previous internal parameter inner to innerException as defined in the approved API scheme.

Added APIs

namespace System.Net;

public partial class CookieException
{
    public CookieException(string? message);
    public CookieException(string? message, Exception? innerException);
 }

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, 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.

1 similar comment
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, 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-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Oct 18, 2024
var exception = new CookieException(message, inner);

Assert.Equal(message, exception.Message);
Assert.Equal(inner, exception.InnerException);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Assert.Equal(inner, exception.InnerException);
Assert.Same(inner, exception.InnerException);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There would be no difference in result, if I use Same.
Exception is an reference type with no Equals overload, so it already compares the reference.

https://sharplab.io/#v2:EYLgtghglgdgNAFxAJwK4wD4AEBMBGAWAChiA3CZAAgFMBHVCAGz0oF5KZqB3SgUQA8AxtQAOCKAHsYACgBEAQVkBKANxkKNekxxsO3PkNHipcxauLEseAJzSAJLN5bGISgG86DZm3aftAX2U1IitbBycvVzcAJWoAM2pkahhhCKYAZ2k/ZjhNLxwlQNUgA=

@deeprobin deeprobin marked this pull request as ready for review October 18, 2024 21:25
Copy link
Member

@MihaZupan MihaZupan left a comment

Choose a reason for hiding this comment

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

Thanks

Comment on lines +21 to +23
/// <remarks>
/// The value of <paramref name="message"/> is stored in the <see cref="Exception.Message"/> property of the new instance.
/// </remarks>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// <remarks>
/// The value of <paramref name="message"/> is stored in the <see cref="Exception.Message"/> property of the new instance.
/// </remarks>

/// and a reference to the inner exception that is the cause of this exception.
/// </summary>
/// <param name="message">A <see cref="string"/> that describes the error that occurred.</param>
/// <param name="innerException">A nested <see cref="Exception"/>.</param>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// <param name="innerException">A nested <see cref="Exception"/>.</param>
/// <param name="innerException">The exception that is the cause of the current exception.</param>

Comment on lines +34 to +37
/// <remarks>
/// The value of <paramref name="message"/> is stored in the <see cref="Exception.Message"/> property of the new instance.
/// The value of <paramref name="message"/> is stored in the <see cref="Exception.InnerException"/> property of the new instance.
/// </remarks>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// <remarks>
/// The value of <paramref name="message"/> is stored in the <see cref="Exception.Message"/> property of the new instance.
/// The value of <paramref name="message"/> is stored in the <see cref="Exception.InnerException"/> property of the new instance.
/// </remarks>

Copy link
Member

Choose a reason for hiding this comment

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

I think you'll have to include a reference to the new file in the test csproj.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Net community-contribution Indicates that the PR has been added by a community member new-api-needs-documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: public ctor for CookieException with string parameter
3 participants