Use new document formatting service when generating types#55463
Use new document formatting service when generating types#55463davidwengier merged 21 commits intodotnet:mainfrom
Conversation
The service simply iterates through a number of providers and calls each one in turn, building up the new document as it goes.
src/Analyzers/Core/CodeFixes/FileHeaders/AbstractFileHeaderCodeFixProvider.cs
Outdated
Show resolved
Hide resolved
| { | ||
| } | ||
|
|
||
| protected override string Language => LanguageNames.CSharp; |
There was a problem hiding this comment.
interesting. do you need this given that the service was already exported for C# anyways?
There was a problem hiding this comment.
also, dumb question, but does your system make sure that if it can't get an INewDocumentFormattingService that that's ok? we need to make sure we don't break F#/TS
There was a problem hiding this comment.
do you need this
This is needed to filter the providers by metadata in the base class. If they were filtered at this level, it would have to be in the base(..) constructor call, which would defeat the purpose of the lazy (I think?)
| var addedDocument = forkedSolution.GetDocument(documentId)!; | ||
|
|
||
| // Call out to various new document formatters to tweak what they want | ||
| var formattingService = addedDocument.GetRequiredLanguageService<INewDocumentFormattingService>(); |
There was a problem hiding this comment.
what ensures that this exists? for example, for F#/TS?
There was a problem hiding this comment.
Am I wrong in ascribing meaning to the absence of F#/TS implementations of AbstractEditorFactory? I guess they could use IVT.. It didn't seem like much of the other code was defensive though. Surely document.GetRequiredSyntaxRoot would fail for TS documents?
I can just make it resilient anyway though, this is the only spot that would need to change anyway.
This builds on #55432 so only review from
6342b87(#55463) onwards. Will rebase etc. when that is merged.This makes Generate Type use the new document formatting service, which realistically means Generate Type now supports file header templates from .editorconfig, and using directive placement options.