-
Notifications
You must be signed in to change notification settings - Fork 226
Settings.UseResharper
Adds // ReSharper disable All to the top of each generated file, so ReSharper stops inspecting code you did not write.
| Type | bool |
| Default |
true in the shipped Database.tt
|
| Applies to | EF 6 and EF Core |
| Databases | All |
In Database.tt? |
Yes |
The
Settingsclass field initialiser isfalse, but the shippedDatabase.ttassignstrue, and the.ttis the line that runs. If you have never touched this setting, it is on.
One line, immediately after the <auto-generated> marker:
// <auto-generated>
// ReSharper disable All
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata.Builders;ReSharper - and Rider, which shares the engine - stops all inspections for the rest of the file.
Generated code trips a lot of inspections that are perfectly reasonable rules for hand-written code and meaningless here: redundant qualifiers, properties that could be made read-only, virtual members in a non-sealed class, naming that follows the database rather than your conventions. None of them are actionable, because the file is regenerated.
Leave it on if anyone on the team uses ReSharper or Rider. It costs one line and removes a permanent column of yellow from a file nobody will fix.
Turn it off if nobody does. The comment is inert without the tool, so it is one line of noise.
Turn it off if you deliberately want the inspections - occasionally useful when you are editing the
templates in EF.Reverse.POCO.v4.ttinclude and want to see what the output trips.
disable All is a blunt instrument, deliberately. It suppresses everything for the whole file with no
matching restore. That is right for generated code and would be wrong anywhere else.
It does nothing about compiler warnings. ReSharper inspections and Roslyn warnings are different things.
For the compiler's "missing XML comment", see Settings.UsePragma.
Rider honours it; the dotnet build command line does not care either way. If your CI fails on warnings,
this setting is not what will fix it.
Turning it on does not stop ReSharper reformatting the file if you have "reformat on save" enabled and you open the generated file. Nothing here prevents that; do not edit generated files.
- Settings.UsePragma - the compiler warning equivalent
- Settings.UseRegions | Settings.AdditionalFileHeaderText - the other "top of the file" settings
- Settings Reference
- Home
- Compared with the Microsoft scaffolder
- Connection strings
- JetBrains Rider
- Upgrading from v3 to v4
- Saving .tt does nothing
- 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