-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add inheritdoc to migration files #10695
Comments
@MaklaCof We will have a think about adding XML comments to the generated code, but we don't plan to do it at the present time. Beyond that, we don't want to generate this pragma all the time because most people will not need it. However, there is a similar discussion about auto-generated in issue #10203. I posted a code snippet in that issue showing how to override the generator to add a line--this should also work for the pragma. |
For reference in this ticket, this is what I used to generate the pragma's: public class FooMigrationsGenerator : CSharpMigrationsGenerator
{
private const string PragmaWarningDisable = @"#pragma warning disable 1591";
private const string PragmaWarningRestore = @"#pragma warning restore 1591";
public FooMigrationsGenerator(
MigrationsCodeGeneratorDependencies dependencies, CSharpMigrationsGeneratorDependencies csharpDependencies)
: base(dependencies, csharpDependencies)
{
}
public override string GenerateMigration(string migrationNamespace, string migrationName,
IReadOnlyList<MigrationOperation> upOperations,
IReadOnlyList<MigrationOperation> downOperations)
{
return PragmaWarningDisable
+ Environment.NewLine
+ base.GenerateMigration(migrationNamespace, migrationName, upOperations, downOperations)
+ Environment.NewLine
+ PragmaWarningRestore
+ Environment.NewLine;
}
public override string GenerateMetadata(string migrationNamespace, Type contextType, string migrationName,
string migrationId, IModel targetModel)
=> PragmaWarningDisable
+ Environment.NewLine
+ base.GenerateMetadata(migrationNamespace, contextType, migrationName, migrationId, targetModel)
+ Environment.NewLine
+ PragmaWarningRestore
+ Environment.NewLine;
} Together with this class somewhere in the starting assembly: public class DesignTimeServices : IDesignTimeServices
{
/// <inheritdoc />
public void ConfigureDesignTimeServices(IServiceCollection services)
{
// Register custom migration generator which adds a pragma disable for xml-comments
services.AddSingleton<IMigrationsCodeGenerator, FooMigrationsGenerator>();
}
} |
This doesn't work anymore with version 3.1.1. |
@ErikEJ Does anything else changed? Class But there are no methods: My Packages are:
|
Possibly, since you are using Internal classes |
I think this should really be implemented. The counter-arguments
are imho invalid, because:
|
Opening to re-discuss in triage. |
This does seem reasonable to do. We should consider using |
Note from triage: use inheritdoc for this. |
Please do consider this for next release. XML comments are not the only ones causing annoying warnings. Each new Migration file triggers several warnings. I need to disable at least those manually: CA1814 is mostly caused by seeding using "HasData" |
@jeancallisti CS8625 (nullability) is covered by #18950. But I'll look into CA1814 when doing this. |
And suppress CA1814 if multidimensional seed data is present. Closes dotnet#10695
And suppress CA1814 if multidimensional seed data is present. Closes dotnet#10695
And suppress CA1814 if multidimensional seed data is present. Closes dotnet#10695
And suppress CA1814 if multidimensional seed data is present. Closes dotnet#10695
And suppress CA1814 if multidimensional seed data is present. Closes #10695
It would be nice if
dotnet ef migrations add
would automatically addto the beginning of generated file and
at the end of file.
I mean both (migrations and designer).
For example:
The text was updated successfully, but these errors were encountered: