Skip to content
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

Migrations: Make generated code play well with StyleCop #7189

Closed
patriksvensson opened this issue Dec 5, 2016 · 12 comments
Closed

Migrations: Make generated code play well with StyleCop #7189

patriksvensson opened this issue Dec 5, 2016 · 12 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. good first issue This issue should be relatively straightforward to fix. help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. type-enhancement
Milestone

Comments

@patriksvensson
Copy link

Steps to reproduce

Add a new migration

The issue

Let me start with saying "Thanks for an awesome project".

This isn't a huge problem, but for all of us that uses StyleCop, adding a new migration creates a lot of warnings (and errors for release builds where warnings-as-errors are enabled).

  • Namespaces in Migrations/MyAppDbContextModelSnapshot are not ordered alphabetically.
  • Namespaces in Migrations/20161205224611_MyMigration.cs are not ordered alphabetically.
  • Namespaces in Migrations/20161205224611_MyMigration.Designer.cs are not ordered alphabetically.
  • Access modifier for Migrations/MyAppDbContextModelSnapshot class is implicit.
  • Access modifier for Migrations/20161205224611_MyMigration.Designer.cs class is implicit.

I would be happy to provide a PR to fix this if you think it's worth doing.
Another solution to this would be to add the standard <auto-generated> header to the generated files.

Further technical details

EF Core version: (found in project.json or packages.config)
Operating system: Windows 10
Visual Studio version: VS 2015

@bricelam
Copy link
Contributor

bricelam commented Dec 6, 2016

The implicit modifiers in the .Designer partial classes is by design. It allows you to change the class's access in a single location--the migration file. We could probably mark those files as auto-generated since they'll rarely have to be modified after being generated.

@rowanmiller
Copy link
Contributor

@patriksvensson we'd love to take a PR on this one. Here is what we think should be done...

  • Add <auto-generated> to the .designer files and to the model snapshot
  • Do the alphabetical sorting of using statements

@rowanmiller rowanmiller changed the title Generated code for migrations does not play well with StyleCop Migrations: Make generated code play well with StyleCop Dec 12, 2016
@rowanmiller rowanmiller added type-enhancement help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. labels Dec 12, 2016
@rowanmiller rowanmiller added this to the Backlog milestone Dec 12, 2016
@rowanmiller
Copy link
Contributor

Putting on the backlog, but we'd take the PR into 1.2 if it is ready in time.

@patriksvensson
Copy link
Author

@rowanmiller I can submit a PR for this, but I'm not sure when 1.2 is due (the milestone gives me no information about this).

@rowanmiller
Copy link
Contributor

@patriksvensson if you can get it in sometime in the next month or so that would give us time to have it in one of the pre-releases for the next release.

@patriksvensson
Copy link
Author

@rowanmiller Sounds good to me. I have plenty of free time the next month or so, so sign me up for this one.

@bricelam
Copy link
Contributor

Here's where to start digging in: CSharpMigrationsGenerator 😉

@bricelam bricelam self-assigned this Apr 4, 2017
@bricelam bricelam modified the milestones: 2.0.0, Backlog Apr 4, 2017
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Apr 4, 2017
@simra
Copy link

simra commented Nov 19, 2018

Hi, I don't want to re-open this issue but I wonder if it's somehow related to this one, which I encountered while running migrations during a publish step: StyleCop/StyleCop#201 Any insights or suggestions would be appreciated.

@bricelam
Copy link
Contributor

Doesn't seem related

@bricelam bricelam added good first issue This issue should be relatively straightforward to fix. and removed good first issue This issue should be relatively straightforward to fix. labels May 31, 2019
@ajcvickers ajcvickers modified the milestones: 2.0.0-preview1, 2.0.0 Oct 15, 2022
@patriksvensson
Copy link
Author

Is there a specific reason this PR was reverted (or, rather, the functionality was removed)?

I'm seeing my analyzers light up like a Christmas tree after revisiting the project after a couple of years, and the <autogenerated /> tag is no longer added to new migrations.

@vslee
Copy link

vslee commented Jul 5, 2023

Looks like it's still there:

=> builder.AppendLine("// <auto-generated />");

@patriksvensson
Copy link
Author

Odd, because it's not being added to new migrations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. good first issue This issue should be relatively straightforward to fix. help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. type-enhancement
Projects
None yet
Development

No branches or pull requests

6 participants