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

SA1642 (summary text) misleading for private constructors #413

Closed
sharwell opened this issue Jan 24, 2015 · 2 comments · Fixed by #416
Closed

SA1642 (summary text) misleading for private constructors #413

sharwell opened this issue Jan 24, 2015 · 2 comments · Fixed by #416
Assignees
Milestone

Comments

@sharwell
Copy link
Member

Currently the following constructor results in SA1642:

/// <summary>
/// Initializes a new instance of the <see cref="ApiStatus"/> class with the specified name.
/// </summary>
private ApiStatus(string name)
    : base(name)
{
}

The expected text is the following:

Prevents a default instance of the <see cref="ApiStatus"/> class from being created.

The currently expected text is simply not correct in this case.

Proposal

  1. SA1642 should allow either the "non-private" or "private" forms for private constructors.
  2. When generating text for a private constructor, the current "non-private" form should be used as the template for this text. Users who are writing new APIs and truly wish to prevent an instance of the type from being created can do so by making static class. We can safely assume that users writing private instance constructors are actually just controlling the manner in which instances are created.
@sharwell sharwell added the bug label Jan 24, 2015
@sharwell sharwell added this to the 1.0.0 Alpha 2 milestone Jan 24, 2015
@sharwell sharwell added bug and removed bug labels Jan 24, 2015
@sharwell
Copy link
Member Author

I initially assigned @pdelvo since he did a great job with the initial implementation. I'll take a look soon if you don't have time.

@sharwell
Copy link
Member Author

I decided to take a look at this one 👟

@sharwell sharwell assigned sharwell and unassigned pdelvo Jan 24, 2015
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Jan 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment