Giter VIP home page Giter VIP logo

Comments (11)

domholmes avatar domholmes commented on August 11, 2024 16

Any update on this? Love the tool but it would be great for a IDE1006 naming 'fix all'.

from format.

JoeRobich avatar JoeRobich commented on August 11, 2024 4

Hi @nikolamalesevic, @jmarolf and I are working on getting analyzer support into a dotnet-format release. If you take our latest development build from our myget feed, you will see the progress that we've made so far.

Here is the output from running dotnet-format ./format.sln --fix-style warn --check -v diag

  The dotnet CLI version is '5.0.100-preview.6.20277.3'.
  Using MSBuild.exe located in '/usr/local/share/dotnet/sdk/5.0.100-preview.6.20277.3/'.
  Formatting code files in workspace '/Users/joeyrobichaud/Source/format/format.sln'.
  Loading workspace.
  Complete in 5688ms.
  Determining formattable files.
  Complete in 915ms.
  Running formatters.
  Running Code Style analysis.
  Determining diagnostics...
  src/CodeFormatter.cs(25,64): Naming rule violation: Missing prefix: 's_' (IDE1006)
  src/Workspaces/FolderWorkspace.cs(4,1): Using directive is unnecessary. (IDE0005)
  tests/Analyzers/FilterDiagnosticsTests.cs(3,1): Using directive is unnecessary. (IDE0005)
  tests/Analyzers/FilterDiagnosticsTests.cs(7,1): Using directive is unnecessary. (IDE0005)
  tests/Analyzers/FilterDiagnosticsTests.cs(12,1): Using directive is unnecessary. (IDE0005)
  Complete in 26650ms.
  Fixing diagnostics...
  Unable to fix IDE0005. No associated code fix found.
  Unable to fix IDE1006. Code fix NamingStyleCodeFixProvider doesn't support Fix All in Solution.
  Complete in 1208ms.
  Analysis complete in 27858ms.
  Complete in 28948ms.
  Formatted 0 of 78 files.
  Format complete in 35551ms.

I introduced a naming issue to show that we can now report naming violations. The next step will be improving our code fix support to work around provider that do not support fix all in solution.

You can try this out yourself by installing our latest development build with the caveat that the feature isn't 100% baked. For instance Full Framework or NetStandard projects may report compilation errors around unresolved dependencies.

dotnet tool install -g dotnet-format --version 5.0.135801 --add-source https://dotnet.myget.org/F/format/api/v3/index.json

-Joey

*Edit: The timings in the log are for a local debug build. Running with the tool built in release mode completes in just under 11 seconds.

from format.

JoeRobich avatar JoeRobich commented on August 11, 2024 3

Hi @Loreno10, currently format does not support naming styles. From our perspective there are 3 types of configuration in the editorconfig; whitespace, code style, and naming. We launched with support for whitespace formatting and are close to merging in initial support for code style. Naming will come later after we have improved the performance of the code style formatting.

from format.

nikolamalesevic avatar nikolamalesevic commented on August 11, 2024

@JoeRobich Any update on this? Are there any guidelines for prospective contributors for a feature like this one?

from format.

ivribalko avatar ivribalko commented on August 11, 2024

Hi @JoeRobich ! Thank you for the awesome tool! It seems that this page contains information suggesting that naming issues fixing should work. I wasn't able to make it work on version 5.0.135301+b255ad16af715cae7bf2a80cc1db697742f46d96. Could you clarify please if it has been implemented or when it might be if not?

from format.

floppydisken avatar floppydisken commented on August 11, 2024

@JoeRobich awesome bloody tool.
So just to be clear, does dotnet format expect NamingStyleFixProvider to be provided from somewhere else?
If so, where is it expected to be provided from?

from format.

JoeRobich avatar JoeRobich commented on August 11, 2024

So just to be clear, does dotnet format expect NamingStyleFixProvider to be provided from somewhere else?

The NamingStyleCodeFixProvider is present but does not provide a batch fixer as other code style fix providers do. We would need to either enhance the Roslyn CodeFixerProvider with this capability or update dotnet-format to handle these diagnostics differently.

from format.

floppydisken avatar floppydisken commented on August 11, 2024

@JoeRobich Ah okay, that makes sense. I'd love for this to be added. It's incredible useful to have a formatter do these things, especially if you pair it with pre-commit hooks.

I have absolutely no idea of the complexity of such a feature. However, is it something we/I can help out with, and if so, where is a good place to start?

from format.

benc-uk avatar benc-uk commented on August 11, 2024

I'd just like dotnet format --verify-no-changes to pick up errors with the names in the code. I'm less interested in fixing

It's super weird seeing red lines in the IDE (VS Code) and dotnet format simply ignoring them

from format.

Sakyawira avatar Sakyawira commented on August 11, 2024

Hi @JoeRobich iI couldn't find that version (version 5.0.135801) you mentioned.

running the command dotnet tool install -g dotnet-format --version 5.0.135801 --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json

gives me this result:

warning NU1603: restore depends on dotnet-format (>= 5.0.135801) but dotnet-format 5.0.135801 was not found. An approximate best match of dotnet-format 5.0.211103 was resolved. You can invoke the tool using the following command: dotnet-format Tool 'dotnet-format' (version '5.0.211103') was successfully installed.

from format.

JoeRobich avatar JoeRobich commented on August 11, 2024

@Sakyawira The versions that ship with the .NET 6 and .NET 7 SDK support reporting naming style violations. There is still no batch fixer implemented for Naming Style errors. See this Roslyn feature request dotnet/roslyn#14983

from format.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.