N.EntityFrameworkCore.Extensions icon indicating copy to clipboard operation
N.EntityFrameworkCore.Extensions copied to clipboard

Code cleanup and improvements

Open SpaceOgre opened this issue 1 year ago • 3 comments

Not sure if you would like help with this but I saw some things that could be improved in the code and also structure it so it is easier to maintain and get into.

Creating this issue first before I do anything that you might not want any way.

Suggestions:

  • [x] Add an .editorconfig file to enforce code standards in the solution
    • [x] Run dotnet format after this and submit a PR with all fixes this produces
  • [ ] Since only Net 8 is targeted go over and use collection initializers where possible
  • [ ] Use char methods where possible, like in CommonUtil.cs since this has better performance
  • [ ] Use StringBuilder where possible for better performance and less allocations
  • [ ] Order methods by their access level, so like public, internal, protected, private
  • [ ] internal classes can be sealed, small performance boost
  • [ ] Group overload methods together
  • [ ] Remove code that is commented out
  • [ ] In LinqExtensions instead of dictionary sqlExpressionTypes, a switch expression will be faster
    • [ ] Look for similar improvements
  • [ ] See if Spans can be used instead of other collections/strings

There is more but starts with this to see if you want help with this and if so how you would like to proceed since it might create lots of conflicts for some of the changes.

SpaceOgre avatar May 29 '24 06:05 SpaceOgre

SpaceOrge,

These are all great suggestions, and I would definitely accept any help to improve this library so feel free to contribute whatever you like. I don't see any issue with all the points that you mentioned so far. I would ask that any pull requests you do go to the development branch.

In regards to .editorconfig file, I am not very familiar it, since I have never used it before, but I think it is a great idea and I am going to look into it tonight. Do you have a basic starter file that I could review?

NorthernLight1 avatar May 29 '24 20:05 NorthernLight1

I have used the .editorconfig that the dotnet team uses as a starter before and are happy with that: https://github.com/dotnet/runtime/blob/main/.editorconfig

Then you have one example in the docs: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options Not sure if it is completely the same but both would probably be a good start. It is a really nice way to define the code style you want to have in your project and is supported by lots of different IDEs :)

SpaceOgre avatar May 30 '24 05:05 SpaceOgre

I researched it yesterday and I agree we should adopt it into this project. The file you suggested looks good. I would say lets start with that one and change it as needed.

NorthernLight1 avatar May 31 '24 00:05 NorthernLight1

I am closing this ticket, we can re-open if there is any progress.

NorthernLight1 avatar Sep 04 '24 13:09 NorthernLight1