Skip to content

"Don't pass a nullable value type as an in argument." #32594

@carlreinke

Description

@carlreinke

Don't pass a nullable value type as an in argument. The Nullable type isn't declared as a read-only struct. That means the compiler must generate defensive copies for any nullable value type argument passed to a method using the in modifier on the parameter declaration.

I think this guidance is a bit too strong. Roslyn (v3.2 and later) does not make defensive copies when accessing some members of Nullable<T> even when targeting .NET Framework (where none of its members are readonly).


Document Details

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


Associated WorkItem - 54744

Metadata

Metadata

Assignees

Labels

📌 seQUESTeredIdentifies that an issue has been imported into Quest.advanced-concepts/subsvcdotnet-csharp/svcokr-qualityContent-quality KR: Concerns article defects (bugs), freshness, or build warnings.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions