Skip to content

Get Code Formattig rules #475

Closed Answered by reduckted
workgroupengineering asked this question in Q&A
Discussion options

You must be logged in to vote

Because the options in the .editorconfig file can be set to different values for different types of files, you need to get the options from a document.

VisualStudioWorkspace workspace = await VS.GetMefServiceAsync<VisualStudioWorkspace>();

// We need a file name. For this example, I'm just using the active document, 
// but you can get the file name from somewhere else if you want.
DocumentView documentView = await VS.Documents.GetActiveDocumentViewAsync();

if (documentView is not null)
{
    // Find the document in the workspace.
    DocumentId documentId = workspace
        .CurrentSolution
        .GetDocumentIdsWithFilePath(documentView.FilePath)
        .FirstOrDefault();

    if (d…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@workgroupengineering
Comment options

Answer selected by workgroupengineering
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants