Comments (5)
@feliwir - I'm not working on this, got a newborn 👶 !
from format.
These details now get logged during --dry-run
s. You can try this out with the latest build from MyGet.
dotnet tool install -g dotnet-format --version 3.1.36303 --add-source https://dotnet.myget.org/F/format/api/v3/index.json
from format.
Naive bunch of code from CodeFormatter.cs
after a document is formatted:
//get the differences between the formatted document, and the original
var diffs = await formattedDocument.GetTextChangesAsync(document, cancellationToken);
foreach (var item in diffs)
{
var sourceText = await document.GetTextAsync(cancellationToken);
var fixedText = await document.GetTextAsync(cancellationToken);
var linePositionSpan = sourceText.Lines.GetLinePositionSpan(item.Span);
var sourceLine = sourceText.Lines[linePositionSpan.Start.Line];
var destinationLine = fixedText.Lines[linePositionSpan.Start.Line];
logger.Log("log details above");
}
I imagine in practice there is a bunch more considerations to take into account. For instance certain TextChanges
can likely apply to multiple lines?
I've also no idea on the correct API's to use here, I was just digging about in intellisense.
Sample output (in this case, the displayed line was indented 4 spaces too many):
Formatting code files in project 'dotnet-format'.
CodeFormatter.cs 192 " var diffs = await formattedDocument.GetTextChangesAsync(document, cancellationToken);". New Text: " var diffs = await formattedDocument.GetTextChangesAsync(document, cancellationToken);"
from format.
Well happily accept a PR for this
from format.
Any work being done on this already?
from format.
Related Issues (20)
- Feature Request: Allow format to select only one framework in case of multi-target projects. HOT 1
- Stop dotnet format from removing thrown exceptions HOT 1
- Need to remove RazorCompiler dependency when upgrading to Roslyn 4.10.0 HOT 2
- Why don't you finalize the version? The latest version is 2021 HOT 3
- Repro of files requiring 2 passes of dotnet format to fully format HOT 6
- --binarylog option broken HOT 3
- Please clarify if this tool is actively supported / worked on HOT 2
- Can I use dotnet format to just generate report and not make the changes to the file. HOT 2
- Issue: Limited Scope for Running the Tool on Changed Files in Pull Requests HOT 1
- running dotnet format on my unity project takes over an hour HOT 2
- .net 8.0.2 Blazor `_imports.razor` & using `IDE0005` HOT 4
- Not detect IDE0290. HOT 1
- IDE0051 format issues with Razor code behind files with SDK 8.0.200 HOT 4
- Questions around Contributing to the Repo HOT 5
- dotnet format is now part of the SDK repo HOT 1
- Wrong indentation when using primary constructor
- Simplify interpolation (IDE0071) - false positive with Enum and FormattableString
- CA1067 on C# record implementing a VB.NET interface
- Does not adhere to language set in `DOTNET_CLI_UI_LANGUAGE`
- Line wrapping and indentation of Collection Literals
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from format.