Visualstudio-docs: Following the Immutable namespace example...

Created on 14 Feb 2020  Â·  3Comments  Â·  Source: MicrosoftDocs/visualstudio-docs

Can I kindly suggest that the doc says it is safe to suppress the warning when nested types are actually following the "builder" pattern, as found in System.Collections.Immutable namespace?

I understand that at large, nested types shouldn't be _encouraged_. But there are in fact cases where they actually make a lot of sense, and the builder pattern is one of those. If you have instances you want to be able to carry around as immutable but yet need to be initialized at some point, having a nested builder type for exactly that purpose feels much more elegant than polluting the namespace with a second type for each entity, or creating a new namespace for builders types with almost the exact same name (redundancy).

The way I'm reading the doc right now feels like ignoring this rule is as bad as hiding base class methods (CA1061) or not implementing IDisposable correctly (CA1063). That can't be right given that Microsoft itself chose to go against that rule.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 doc-bug visual-studio-windowprod vs-ide-code-analysitech

All 3 comments

@mavasani Should we say its OK to suppress the warning when nested types are following the builder pattern?

Yes, that sounds reasonable. Seems there is already a feature request to handle this case in the rule: https://github.com/dotnet/roslyn-analyzers/issues/3033

Thanks! Updating doc.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Logerfo picture Logerfo  Â·  3Comments

wellwind picture wellwind  Â·  3Comments

rlundy picture rlundy  Â·  3Comments

gewarren picture gewarren  Â·  3Comments

JeepNL picture JeepNL  Â·  3Comments