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

The proposed fix for CA2208 is not consistent in the doc #44030

Open
longyuan1996 opened this issue Dec 19, 2024 · 5 comments · May be fixed by #44490
Open

The proposed fix for CA2208 is not consistent in the doc #44030

longyuan1996 opened this issue Dec 19, 2024 · 5 comments · May be fixed by #44490
Assignees
Labels
dotnet-fundamentals/svc in-pr This issue will be closed (fixed) by an active pull request. ⌚ Not Triaged Not triaged

Comments

@longyuan1996
Copy link

longyuan1996 commented Dec 19, 2024

Type of issue

Other (describe below)

Description

[Enter feedback here]

Hi, I'm trying to fix the CA2208 error in my project. But in the official documentation, I found that the fixes are totally different in the tip and the example.

In the How to fix violations tip, the parameter name is placed to the 2nd paramenter:
Image

But in the Example Session, the name is placed to the 1st parameter:
Image

From the ArgumentException Constructor (System) | Microsoft Learn the parameter should be in the 2nd parameter.

Page URL

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2208#how-to-fix-violations

Content source URL

https://github.com/dotnet/docs/blob/main/docs/fundamentals/code-analysis/quality-rules/ca2208.md

Document Version Independent Id

cc2b5015-89a9-02ff-a585-fca3449dfa9a

Article author

@gewarren

Metadata

  • ID: ff82be90-2d17-5880-4edd-a89b18a3ae2b
  • Service: dotnet-fundamentals

Related Issues

@BartoszKlonowski
Copy link
Contributor

@gewarren Let me take a look into that and work on it if needed.

@BartoszKlonowski
Copy link
Contributor

BartoszKlonowski commented Jan 22, 2025

@gewarren Yes, I confirm this is the tooltip that requires an update of the screenshots (the code samples from snippets are correct).
The only question is: Is it OK to use the "Blue" theme for new ones (as the Visual Studio changed it's look after those years)?

@BartoszKlonowski
Copy link
Contributor

One more thing: I don't think we will need the second screenshot any longer, as I can see that having single parameter of the type name matches one of the ArgumentNullException overloads:

        public ArgumentNullException(string? paramName)
            : base(SR.ArgumentNull_Generic, paramName)
        {
            HResult = HResults.E_POINTER;
        }

@BartoszKlonowski BartoszKlonowski linked a pull request Jan 22, 2025 that will close this issue
@dotnet-policy-service dotnet-policy-service bot added the in-pr This issue will be closed (fixed) by an active pull request. label Jan 22, 2025
@gewarren
Copy link
Contributor

I believe the doc is actually correct as written. There's a subtle difference here because the parameter order is different between ArgumentException and ArgumentNullException, as noted in the article. Perhaps that part needs to be more prominent? Or maybe we just go ahead and switch the screenshot to the ANE exception.

@gewarren
Copy link
Contributor

One more thing: I don't think we will need the second screenshot any longer, as I can see that having single parameter of the type name matches one of the ArgumentNullException overloads:

This part is also okay as-is. The code fix appears for ArgumentException, where the single string argument constructor takes a message string, not a paramName string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-fundamentals/svc in-pr This issue will be closed (fixed) by an active pull request. ⌚ Not Triaged Not triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants