-
Notifications
You must be signed in to change notification settings - Fork 226
Settings.UsePragma
Adds #pragma warning disable 1591 to the top of each generated file, silencing the "missing XML comment" warning.
| Type | bool |
| Default | false |
| Applies to | EF 6 and EF Core |
| Databases | All |
In Database.tt? |
Yes |
Exactly one line:
// <auto-generated>
#pragma warning disable 1591 // Ignore "Missing XML Comment" warning
using Microsoft.Data.SqlClient;Warning 1591 is "Missing XML comment for publicly visible type or member". It only fires in a project that
has <GenerateDocumentationFile>true</GenerateDocumentationFile>, and in such a project a generated file with
sixty undocumented public properties produces sixty warnings you will never act on.
Turn it on if your project generates an XML documentation file. Otherwise the generated code buries the warnings you actually care about.
Leave it off otherwise. With no documentation file, warning 1591 never fires and the pragma is a line that does nothing.
A .editorconfig rule scoped to the generated file is the tidier alternative if you already maintain one:
[Database.cs]
dotnet_diagnostic.CS1591.severity = noneThat keeps the suppression in your configuration rather than in generated output, and it survives if you later turn this setting off.
It disables only warning 1591. Anything else the generated code triggers - unused usings, naming rules,
nullable warnings - is untouched. Settings.UseResharper covers a different set, and
Settings.AllowNullStrings is what silences the nullable ones.
It is never restored. There is no matching #pragma warning restore, so the suppression applies to the
whole file. That is fine for a file you do not edit, and worth knowing if you were expecting it to be scoped.
Turning on Settings.IncludeComments = CommentsStyle.InSummaryBlock does not remove the need for it. Most
properties get a <summary> that way, but not all members do, so a project requiring documentation still
warns.
- Settings.IncludeComments - generating the XML comments rather than suppressing the warning
- Settings.UseResharper - the ReSharper equivalent
- Settings.AllowNullStrings - the nullable reference type warnings
- Settings Reference
- Settings A-Z - every setting, with a page each
- Common Settings Types Explained
- Settings Callbacks
- Settings runtime values and helpers
- Filtering
- Full Control Over the Generated Code
- Enum Generation from Table Data
- Owned Entities
- JSON column support
- Global Query Filters
- Extended Property Names Feature
- Partial Properties
- File-Scoped Namespaces
- Data Annotations
- Spatial Types
- HierarchyId
- RowVersion and TimeStamp columns
- Lazy Loading
- Stored proc result sets
- Custom File-Based Templates
- Extra entities via partial classes
- INotifyPropertyChanged
- Syntax colour for T4