Open CarryoutRepo opened 1 year ago
thanks this solution is really helpful i forget i use codemaid extension
Thanks for reporting the issue. I have not been able to reproduce it. We do have explicit bypass logic for the partial
keyword on classes but I don't know that we have the same on methods.
Love CodeMaid. I have the same issue as the OP.
For now, I have excluded the dbcontext file from code maid cleanup to solve the problem.
@asichi how do you exclude?
@tombohub Extensions | CodeMaid | Options | Cleaning | File Types | Exclude
Can confirm this is happening for me also.
@asichi absolute lifesaver haha ❤️
I have the same issue on an old project using LinqToSql.
the Designer.cs file generates partial methods on the entities:
partial void OnLoaded();
Then if I implement this partial in another class:
partial void OnLoaded()
{
// do something
}
This gets changed to
private partial void OnLoaded()
{
// do something
}
Resulting in error CS8799 - Both partial method declarations must have identical accessibility modifiers.
Experiencing this issue too, ty @asichi 👍
I am also experiencing this after using EF Core to scaffold my database context.
It generates:
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
In my case, I think I can comment out this method and its reference, but I will need to do this every time I re-scaffold.
Hey @codecadwallader
you said you cannot reproduce this and tagged it as such. Unfortunalty many people (include me) encounter this problem.
Would you be able to investigate this problem again, please?
I use the mvvm toolkit and it the same with changing
methods (https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/generators/observableproperty#running-code-upon-changes)
Can confirm I have experienced the above issue too and the easiest, quickest fix was to exluce the file like @asichi suggested. Thank you
I got the same issue as @hellow554 .
same . I Excluded it
I'm not keen on excluding an entire file. Instead, a better solution might be to disable the automatic insertion of access modifiers on methods.
CodeMaid → Options → Cleaning → Insert → "Insert explicit access modifiers for" → methods
I prefer to disable it this way to ensure that the rest of the file remains clean. Just remember to set your accessibility modifiers from now on. If you already do this like I do, you'll be perfectly fine.
Environment
Description
Entity framework creates a partial void from its template for DbContext that reads...
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
...which CodeMaid adds "private" to like this...
private partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
...which changes the auto-generated code and prevents any builds.
There is no way to fix it if you have CodeMaid on Save on without leaving VS.
Awesome product, THANKS!!!!
Steps to recreate
Create a class with the problem... internal partial class Class1 { partial void OnModelCreatingPartial(int x = 1); }
Run CodeMaid on the class. It will now read... internal partial class Class1 { partial void OnModelCreatingPartial(int x = 1); }
Now the class can't compile because.... CS8795 Partial method 'Class1.OnModelCreatingPartial(int)' must have an implementation part because it has accessibility modifiers.
Current behavior
Adds "private" to a partial void.
Expected behavior
Code maid should not add an accessibility modifier for partial voids.