GU0070
January 8, 2020 ยท View on GitHub
Default-constructed value type with no useful default
| Topic | Value |
|---|---|
| Id | GU0070 |
| Severity | Warning |
| Enabled | True |
| Category | Gu.Analyzers.Correctness |
| Code | GU0070DefaultConstructedValueTypeWithNoUsefulDefault |
Description
Types declared with struct must have a default constructor, even if there is no semantically sensible default value for that type. Examples include System.Guid and System.DateTime.
Motivation
ADD MOTIVATION HERE
How to fix violations
ADD HOW TO FIX VIOLATIONS HERE
Configure severity
Via ruleset file.
Configure the severity per project, for more info see MSDN.
Via #pragma directive.
#pragma warning disable GU0070 // Default-constructed value type with no useful default
Code violating the rule here
#pragma warning restore GU0070 // Default-constructed value type with no useful default
Or put this at the top of the file to disable all instances.
#pragma warning disable GU0070 // Default-constructed value type with no useful default
Via attribute [SuppressMessage].
[System.Diagnostics.CodeAnalysis.SuppressMessage("Gu.Analyzers.Correctness",
"GU0070:Default-constructed value type with no useful default",
Justification = "Reason...")]