Open gpresland opened 5 years ago
Just noticed this too. Should add after namespace but before class declaration in both the migration and it's partial class (in EF core).
I am annoyed by this too. Unfortunately devs do not seem to be wanting to implement this simple fix: https://github.com/dotnet/efcore/issues/10695
I dont understand the actual reason behind not wanting to implement this.
I can't force me and our devs to include XML comments for public APIs by using TreatWarningsAsErrors, if I use migrations. So I'm either stuck with missing API docs or manually adjusting the migration files.
Is there any proper workaround for this?
Well a Workaround would be to wrap dotnet ef migrations add
by a powershell/cmd/bash script that adds the #pragma warning disable CS1591
line to all files in the Migrations
folder that don't already have it. Something like
dotnet ef migrations add ...
for f in $(find Migrations -iname '*.cs')
do
if grep -vq CS1591 $f
then
echo "#pragma warning disable CS1591" > tempfile.tmp
cat $f >> tempfile.tmp
mv tempfile.tmp $f
fi
done
(not tested)
If you have your migrations in their own project, you can solve this with a <CodeAnalysisRuleSet>migrations.ruleset</CodeAnalysisRuleSet>
somewhere inside a <PropertyGroup>
in the .csproj
, and the make the contents of the migrations.ruleset
file similar to the following:
<RuleSet Name="Migrations" ToolsVersion="15.0">
<Rules AnalyzerId="Roslynator.CSharp.Analyzers" RuleNamespace="Roslynator.CSharp.Analyzers">
<Rule Id="CS1591" Action="None" />
</Rules>
</RuleSet>
Condition
Issue
*.cs migrations files cause Visual Studio to output warnings for rule CS1591 (Missing XML comment for publicly visible type or member 'Type_or_Member').
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs1591
Solutions
Generate *.cs migration files should be prepended with: