-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Closed
Labels
📌 seQUESTeredIdentifies that an issue has been imported into Quest.Identifies that an issue has been imported into Quest.advanced-concepts/subsvcdotnet-csharp/svcokr-qualityContent-quality KR: Concerns article defects (bugs), freshness, or build warnings.Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Description
Don't pass a nullable value type as an
inargument. 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 theinmodifier 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.
- ID: ac8804c7-6acd-ab2a-4e14-0b99265969a5
- Version Independent ID: 183efcbd-a781-d303-f9cd-1c22da1676de
- Content: Write safe and efficient C# code
- Content Source: docs/csharp/write-safe-efficient-code.md
- Product: dotnet-csharp
- Technology: csharp-advanced-concepts
- GitHub Login: @BillWagner
- Microsoft Alias: wiwagn
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
📌 seQUESTeredIdentifies that an issue has been imported into Quest.Identifies that an issue has been imported into Quest.advanced-concepts/subsvcdotnet-csharp/svcokr-qualityContent-quality KR: Concerns article defects (bugs), freshness, or build warnings.Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.