Skip to content
Merged
Show file tree
Hide file tree
Changes from 128 commits
Commits
Show all changes
131 commits
Select commit Hold shift + click to select a range
e20715c
adding editorconfig template
jmarolf Apr 11, 2018
c2b847c
in progress
jmarolf Apr 12, 2018
16ef4d7
adding setup
jmarolf Apr 18, 2018
63798e0
wip
jmarolf Apr 18, 2018
5b5cbf2
fixing swr file
jmarolf Apr 18, 2018
75e7da8
updating editorconfig
jmarolf Apr 20, 2018
e7d1a72
adding additional templates
jmarolf Apr 20, 2018
5f47096
Merge pull request #38 from jmarolf/editorconifg-changes
jmarolf Apr 20, 2018
0e2d40b
fixing Kaseys comments
jmarolf Apr 20, 2018
204fd18
Merge pull request #39 from jmarolf/editorconfig-fixes
jmarolf Apr 20, 2018
a51b816
adding localized resources
jmarolf Apr 21, 2018
a7923bd
Merge pull request #40 from jmarolf/editor-config-loc
jmarolf Apr 21, 2018
b81ba3e
update vb authoring
jmarolf Apr 23, 2018
7b6ff0f
Merge pull request #41 from jmarolf/fix-vb-setup-authoring
jmarolf Apr 23, 2018
cf1509d
moving templates and setup to their respective folders
jmarolf Apr 25, 2018
263aa2c
update projects to show content
jmarolf Apr 25, 2018
c1a9b39
rename folder
jmarolf Apr 25, 2018
7d5caae
updating swr files
jmarolf Apr 25, 2018
1876ee3
updating set project names
jmarolf Apr 25, 2018
5650df2
renaming tools projects
jmarolf Apr 25, 2018
14ae3d3
fixing tools references
jmarolf Apr 25, 2018
57afd70
Merge pull request #44 from jmarolf/refactor
jmarolf Apr 25, 2018
8383986
Merge pull request #45 from jmarolf/merges/dev15.8-preview2-to-master
jmarolf Apr 25, 2018
b54f2b0
do not show templates by default, only show them if the proper compat…
jmarolf Apr 27, 2018
8483e7e
& is not valid XML
jmarolf Apr 27, 2018
49179df
Merge pull request #46 from jmarolf/fix-aspnet-node-order
jmarolf Apr 27, 2018
92e0c83
reset to defaults
jmarolf Apr 30, 2018
f38249d
Merge pull request #47 from jmarolf/fix-aspnet-node-order
jmarolf Apr 30, 2018
33c8e57
Merge remote-tracking branch 'upstream/dev15.7.x' into merges/dev15.7…
jmarolf Apr 30, 2018
12ef5ee
Merge pull request #48 from jmarolf/merges/dev15.7.x-to-dev15.8-preview2
jmarolf Apr 30, 2018
53f8943
Merge remote-tracking branch 'upstream/dev15.8-preview2' into merges/…
jmarolf Apr 30, 2018
3feda1d
Merge pull request #49 from dotnet/merges/dev15.8-preview2-to-master
jmarolf Apr 30, 2018
7393b65
adding editorconfig resources
jmarolf May 1, 2018
838620a
removing modified templates
jmarolf May 1, 2018
2694f63
use editorconfig resource strings
jmarolf May 1, 2018
fa02a88
updating loc
jmarolf May 1, 2018
7aca9d5
updating swr files
jmarolf May 1, 2018
e9bf6bf
Merge pull request #50 from jmarolf/update-setup-authoring
jmarolf May 1, 2018
2ce63be
Merge branch 'dev15.8-preview2' into merges/dev15.8-preview2-to-master
jmarolf May 1, 2018
81b3759
Merge pull request #52 from jmarolf/merges/dev15.8-preview2-to-master
jmarolf May 1, 2018
3d618ce
fix setup
jmarolf May 1, 2018
b664cc7
Merge pull request #54 from jmarolf/setup-fix
jmarolf May 1, 2018
752e0e4
Merge remote-tracking branch 'upstream/dev15.8-preview2' into merge-d…
jmarolf May 1, 2018
3eddecf
Merge pull request #55 from jmarolf/merge-dev15.8-preview2-to-master
jmarolf May 1, 2018
4a08a4e
adding VB editorconfig temaplates
jmarolf Jun 4, 2018
b38da43
Merge pull request #56 from jmarolf/update-editorconfig
jmarolf Jun 5, 2018
6a4bf5a
LOC CHECKIN | dotnet/templates master | 20180629
v-zbsail Jun 29, 2018
750c595
Merge pull request #61 from v-zbsail/loc_20180625_master
jmarolf Jul 6, 2018
81d604a
adding new editor config constants
jmarolf Jul 7, 2018
5ce661c
Fix access to resources
jmarolf Jul 18, 2018
961f4bf
Merge pull request #64 from jmarolf/resource-load-fix
jmarolf Jul 18, 2018
13efd90
Update editorconfig default name
jmarolf Aug 23, 2018
67e4e98
Merge pull request #65 from jmarolf/fix-editorconfig-name
jmarolf Aug 24, 2018
f19b021
Trim trailing whitespace in EditorConfig item templates
Jan 1, 2019
2c692ec
Merge pull request #73 from FurkanKambay/master
jmarolf Jan 2, 2019
13a5a99
Corrected two option names
tonyhallett Mar 12, 2019
ee6ea58
Merge pull request #83 from tonyhallett/Correcting_Option_Names
jmarolf Mar 12, 2019
ac52d24
move-to-arcade
jmarolf Apr 13, 2019
b139691
Merge pull request #90 from jmarolf/move-to-arcade
jmarolf Apr 13, 2019
c6687e3
do not build tasks and use nuget package instead
jmarolf Apr 15, 2019
4eeebab
Merge pull request #92 from jmarolf/use-nuget-task
jmarolf Apr 15, 2019
eb4857e
fixing build
jmarolf Jul 16, 2019
0ed1edf
Add new classlib templates (#132)
jmarolf Jul 16, 2019
79a25bb
Pick up EmbeddedResouce items again
tmeschter Jul 22, 2019
3a10ae9
Properly determine the path for a new .editorconfig
tmeschter Jul 22, 2019
a848c7f
adding TFM so the projects open
jmarolf Jul 27, 2019
b2a3239
Fix vs dev (#134)
jmarolf Jul 27, 2019
b6ab0d2
Fix code analysis issues
davidwengier Sep 12, 2019
f0e827f
Remove unnecesary package references
davidwengier Sep 12, 2019
ee1fa44
use ProvideBindingRedirection to find dll
dmonroym Sep 12, 2019
813e9f4
Use PackageRegistration attribute instead
dmonroym Sep 13, 2019
8ea56de
cleanup of InstalledProductRegistration
dmonroym Sep 13, 2019
0cd411a
fix EditorConfig templates names (#193)
dmonroym Sep 13, 2019
e3b3455
update xlf files
jmarolf Sep 13, 2019
e7cd9d0
Merge remote-tracking branch 'upstream/master' into AssemblyInfoWizard
davidwengier Sep 15, 2019
288aa00
Fixes #205: Show the correct filename in the Add Item dialog box for …
davidwengier Oct 3, 2019
b3c1388
Fixes #130: Fix inferred tuple names rule name
davidwengier Oct 3, 2019
6e355d3
Fix Editor config issues (#206)
davidwengier Oct 3, 2019
903e441
LOC CHECKIN | dotnet/templates master | 20191101
v-zbsail Nov 1, 2019
4a5e265
Merge pull request #235 from dotnet/merges/dev15.9.x-to-dev16.0.x
jmarolf Sep 18, 2020
e6866b8
Merge pull request #377 from dotnet/merges/dev15.9.x-to-dev16.0.x
jmarolf Sep 22, 2020
946bfb8
Specify indent_size = 2 for XML in editorconfig (.NET) template
Youssef1313 Apr 9, 2021
800bb91
Fix
Youssef1313 Apr 9, 2021
9627978
Fix
Youssef1313 Apr 9, 2021
37436c4
Localized file check-in by OneLocBuild Task
dotnet-bot May 3, 2021
ffa6dfc
Renormalize files
jonfortescue May 4, 2021
3dc3a7d
Merge pull request #478 from dotnet/locfiles/01794c1b-8440-49e3-b404-…
jmarolf May 4, 2021
632ce48
Update VSSDK
genlu May 6, 2021
45d4ba0
Merge pull request #479 from genlu/update
genlu May 7, 2021
52026b3
Update VS SDK
genlu May 19, 2021
af82228
Merge pull request #487 from genlu/vssdk
genlu May 20, 2021
ac60cf5
Merge pull request #461 from Youssef1313/patch-1
jmarolf May 24, 2021
a9e0f3a
Localized file check-in by OneLocBuild Task
dotnet-bot Jun 22, 2021
33d7977
Localized file check-in by OneLocBuild Task
dotnet-bot Jun 22, 2021
8dc02ae
Localized file check-in by OneLocBuild Task
dotnet-bot Jun 22, 2021
28dd904
Localized file check-in by OneLocBuild Task
dotnet-bot Jun 23, 2021
e23ad7e
Merge pull request #512 from dotnet/locfiles/7259860d-da18-4ed3-a19a-…
jmarolf Jun 23, 2021
a1ffe13
Merge pull request #509 from dotnet/locfiles/67d6aca8-f201-4330-a265-…
jmarolf Jun 23, 2021
14cb4c8
Merge pull request #510 from dotnet/locfiles/a46347e2-4115-4da3-b047-…
jmarolf Jun 23, 2021
afded3f
Merge pull request #511 from dotnet/locfiles/0127e690-59b1-47c4-b06e-…
jmarolf Jun 23, 2021
58a28b2
move to MIT license
jmarolf Jul 27, 2021
f06588a
Localized file check-in by OneLocBuild Task
dotnet-bot Jul 28, 2021
4bdfe78
update editorconfig settings
jmarolf Feb 25, 2022
5442e70
Merge pull request #644 from jmarolf/features/update-default-editorco…
jmarolf Feb 26, 2022
19fc31a
update package versions
jmarolf Apr 18, 2022
5684e8f
update vsix manifests to support 64 bit
jmarolf Apr 18, 2022
02b6fe0
use roslyn options to generate editorconfig
jmarolf Apr 18, 2022
1c3b040
ading right click command
jmarolf Apr 19, 2022
573e4ad
simplify references
jmarolf Apr 19, 2022
840affc
adding telemetry
jmarolf Apr 20, 2022
05b801c
simplify options telemetry
jmarolf Apr 20, 2022
28ba5d1
Change icon from EditorConfigFile to NewDocument
jmarolf May 23, 2022
e7dd95e
Use Document instead of NewDocument
jmarolf May 23, 2022
7aa132c
Merge pull request #677 from jmarolf/bugfix/update-new-editorconfig-icon
jmarolf May 23, 2022
5559cd5
Localized file check-in by OneLocBuild Task: Build definition ID 1007…
dotnet-bot May 23, 2022
a88b7ab
enable nullable
jmarolf Jun 28, 2022
5f055fd
add nullable annotations
jmarolf Jun 28, 2022
8747a6e
Merge pull request #692 from jmarolf/bugfix/enable-nullable
jmarolf Jun 28, 2022
257f5aa
Merge pull request #678 from dotnet/locfiles/52c4e69d-40f5-4b2a-916d-…
jmarolf Jul 1, 2022
fc7e19b
Fix EditorConfig at solution level (#782)
beccamc Nov 29, 2023
b48c8fd
Localized file check-in by OneLocBuild Task: Build definition ID 1007…
dotnet-bot Nov 29, 2023
858fd56
Relocate EditorConfig templates for Roslyn import
JoeRobich Sep 3, 2026
7bc126a
Merge dotnet/templates EditorConfig history
JoeRobich Sep 3, 2026
2eaca5e
Integrate EditorConfig templates into Roslyn
JoeRobich Sep 3, 2026
6e53187
Document Visual Studio EditorConfig projects
JoeRobich Sep 3, 2026
0c956b3
Normalize imported EditorConfig whitespace
JoeRobich Sep 3, 2026
60622e1
Adapt EditorConfig Visual Studio packaging
JoeRobich Sep 3, 2026
f1f7cd9
Include EditorConfig VSIX manifests
JoeRobich Sep 3, 2026
393d34f
Unify TemplateWizardInterface version
JoeRobich Sep 4, 2026
d2b36cb
Fix EditorConfig correctness diagnostics
JoeRobich Sep 4, 2026
e49c1db
Restore EditorConfig setup package identity
JoeRobich Sep 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/instructions/IDE.instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Roslyn uses a **layered service architecture** built on MEF (Managed Extensibili
- **LanguageServer** (`src/LanguageServer/`): Shared LSP protocol implementation and Roslyn LSP executable (`roslyn-language-server`)
- **EditorFeatures** (`src/EditorFeatures/`): VS Editor integration and text manipulation
- **VisualStudio** (`src/VisualStudio/`): Visual Studio-specific implementations
- **EditorConfig templates** (`src/VisualStudio/EditorConfig/`): item templates, generation wizard, context-menu command, VSIX projects, and Visual Studio insertion setup

### Service Resolution
```csharp
Expand Down
2 changes: 1 addition & 1 deletion .github/memory/FILE_MAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This file is a **top-level map only**. For per-area directory detail, read the m
| `Features/`, `EditorFeatures/` | ide | IDE feature logic and editor integration. |
| `Analyzers/`, `CodeStyle/` | ide | IDE0xxx code-style analyzers & fixes. |
| `LanguageServer/` | ide | LSP server. |
| `VisualStudio/` | ide | VS language services & UI. |
| `VisualStudio/` | ide | VS language services, UI, and EditorConfig template/wizard/command packaging under `EditorConfig/`. |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change.

| `Razor/src/` | razor | Razor compiler + tooling (own sub-tree layout). |
| `Scripting/`, `Interactive/` | — | C#/VB scripting engine and REPL. |
| `RoslynAnalyzers/` | — | Shipping `Microsoft.CodeAnalysis.*` analyzer packages. |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ BenchmarkDotNet.Artifacts/
[Bb]inaries/
[Bb]in/
[Oo]bj/
src/VisualStudio/EditorConfig/Templates/ModifiedTemplates/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that should be landing in artifacts?

.dotnet/
.tools/
.packages/
Expand Down
5 changes: 5 additions & 0 deletions Ide.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@
"src\\VisualStudio\\Core\\Test.Next\\Roslyn.VisualStudio.Next.UnitTests.csproj",
"src\\VisualStudio\\Core\\Test\\Microsoft.VisualStudio.LanguageServices.UnitTests.vbproj",
"src\\VisualStudio\\DevKit\\Impl\\Microsoft.VisualStudio.LanguageServices.DevKit.csproj",
"src\\VisualStudio\\EditorConfig\\Command\\Microsoft.VisualStudio.Templates.Editorconfig.Command.csproj",
"src\\VisualStudio\\EditorConfig\\Setup\\Microsoft.VisualStudio.Templates.Editorconfig.Setup.csproj",
"src\\VisualStudio\\EditorConfig\\Templates\\Microsoft.VisualStudio.Templates.Editorconfig.csproj",
"src\\VisualStudio\\EditorConfig\\Wizard\\Microsoft.VisualStudio.Templates.Editorconfig.Wizard.csproj",
"src\\VisualStudio\\EditorConfig\\WizardSetup\\Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Setup.csproj",
"src\\VisualStudio\\ExternalAccess\\Apex\\Microsoft.CodeAnalysis.ExternalAccess.Apex.csproj",
"src\\VisualStudio\\ExternalAccess\\Core\\Microsoft.VisualStudio.LanguageServices.ExternalAccess.csproj",
"src\\VisualStudio\\ExternalAccess\\Copilot\\Microsoft.VisualStudio.LanguageServices.ExternalAccess.Copilot.csproj",
Expand Down
7 changes: 7 additions & 0 deletions Roslyn.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@
<Project Path="src/VisualStudio/VisualStudioDiagnosticsToolWindow/Roslyn.VisualStudio.DiagnosticsWindow.csproj" />
<Project Path="src/VisualStudio/Xaml/Impl/Microsoft.VisualStudio.LanguageServices.Xaml.csproj" />
</Folder>
<Folder Name="/VisualStudio/EditorConfig/">
<Project Path="src/VisualStudio/EditorConfig/Command/Microsoft.VisualStudio.Templates.Editorconfig.Command.csproj" />
<Project Path="src/VisualStudio/EditorConfig/Setup/Microsoft.VisualStudio.Templates.Editorconfig.Setup.csproj" />
<Project Path="src/VisualStudio/EditorConfig/Templates/Microsoft.VisualStudio.Templates.Editorconfig.csproj" />
<Project Path="src/VisualStudio/EditorConfig/Wizard/Microsoft.VisualStudio.Templates.Editorconfig.Wizard.csproj" />
<Project Path="src/VisualStudio/EditorConfig/WizardSetup/Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Setup.csproj" />
</Folder>
<Folder Name="/VisualStudio/ExternalAccess/">
<Project Path="src/VisualStudio/ExternalAccess/Apex/Microsoft.CodeAnalysis.ExternalAccess.Apex.csproj" />
<Project Path="src/VisualStudio/ExternalAccess/Core/Microsoft.VisualStudio.LanguageServices.ExternalAccess.csproj" />
Expand Down
7 changes: 7 additions & 0 deletions eng/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
Visual Studio
-->
<PackageVersion Include="EnvDTE" Version="18.9.438" />
<PackageVersion Include="EnvDTE80" Version="18.9.438" />
<PackageVersion Include="Microsoft.Internal.VisualStudio.Interop" Version="18.9.438" />
<PackageVersion Include="Microsoft.Internal.VisualStudio.Shell.Framework" Version="18.0.1211-preview.1" />
<PackageVersion Include="Microsoft.ServiceHub.Client" Version="4.6.3200" />
Expand All @@ -93,13 +94,18 @@
<PackageVersion Include="Microsoft.VisualStudio.LiveShare.LanguageServices" Version="3.0.6" />
<PackageVersion Include="Microsoft.VisualStudio.LiveShare.LanguageServices.Guest" Version="3.0.6" />
<PackageVersion Include="Microsoft.VisualStudio.LiveShare.WebEditors" Version="3.0.8" />
<PackageVersion Include="Microsoft.VisualStudio.OLE.Interop" Version="18.9.438" />
<PackageVersion Include="Microsoft.VisualStudio.ProjectSystem" Version="17.3.195-pre" />
<PackageVersion Include="Microsoft.VisualStudio.SDK" Version="18.9.496-Preview" />
<PackageVersion Include="Microsoft.VisualStudio.SDK.Analyzers" Version="17.7.122" />
<PackageVersion Include="Microsoft.VisualStudio.Search" Version="17.14.39337" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.Interop" Version="18.9.438" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.Interop.10.0" Version="18.9.438" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.Interop.8.0" Version="18.9.438" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.Interop.9.0" Version="18.9.438" />
<PackageVersion Include="Microsoft.VisualStudio.Shell.Styles" Version="18.9.918" />
<PackageVersion Include="Microsoft.VisualStudio.TemplateWizardInterface" Version="17.2.32414.248" />
<PackageVersion Include="Microsoft.VisualStudio.TextManager.Interop" Version="18.9.438" />
<PackageVersion Include="Microsoft.VisualStudio.TextManager.Interop.8.0" Version="18.9.438" />
<PackageVersion Include="Microsoft.VisualStudio.Validation" Version="18.7.1" />
<PackageVersion Include="Microsoft.VisualStudio.VsInteractiveWindow" Version="4.0.0" />
Expand Down Expand Up @@ -149,6 +155,7 @@
<PackageVersion Include="Nerdbank.MessagePack" Version="1.2.34" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
<PackageVersion Include="StreamJsonRpc" Version="2.26.10" />
<PackageVersion Include="UpdateTemplateVersion" Version="1.0.0" />

<!--
VS Debugger
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Generator;
using Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Logging.Kinds;
using Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Utilities;
using System.ComponentModel.Design;
using System.Threading.Tasks;
using static Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Logging.Logger;

namespace Microsoft.VisualStudio.Templates.Editorconfig.Command.Commands;

internal class AddEditorConfigFileCommand : CommandBase
{
protected override CommandID Id { get; } = new CommandID(PackageGuids.AddEditorConfigCmdSet, PackageIds.AddEditorConfigFileCommand);

protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
using var _ = LogUserAction(UserTask.CreateFromRightClickMenu);
if (Package is not null)
{
await Package.JoinableTaskFactory.SwitchToMainThreadAsync(Package.DisposalToken);
var (success, fileName) = EditorConfigFileGenerator.TryAddFileToSolution();
Assert(success, "Unable to add the editorconfig file to the solution");

if (success && fileName is not null)
{
VSHelpers.OpenFile(fileName);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Generator;
using Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Logging.Kinds;
using Microsoft.VisualStudio.Workspace.VSIntegration.UI;
using System.Collections.Generic;
using System.ComponentModel.Design;
using static Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Logging.Logger;

namespace Microsoft.VisualStudio.Templates.Editorconfig.Command.Commands;

internal class AddEditorConfigFileCommandHandler : CommandHandlerBase
{
protected override CommandID Id { get; } = new CommandID(PackageGuids.AddEditorConfigCmdSet, PackageIds.AddEditorConfigFileAnyCodeCommand);

protected override bool QueryStatus(List<WorkspaceVisualNodeBase> selection)
=> selection.Count == 1 && selection[0] is IFolderNode;
Comment on lines +18 to +19

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which command is this defined for? Are we loading this package/DLL just to proffer a command like this? I'm just wondering if we were to pull this into any of our existing assemblies we can remove a DLL load.


protected override bool Execute(List<WorkspaceVisualNodeBase> selection)
{
Assert(selection.Count == 1, "Multiple items selected");
if (selection.Count == 1 && selection[0] is IFolderNode folder)
{
using var _1 = LogUserAction(UserTask.CreateFromRightClickMenuAnyCode);
_ = EditorConfigFileGenerator.TryAddFileToFolder(folder.FullPath);
return true;
}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.VisualStudio.Workspace.VSIntegration.UI;
using System.ComponentModel.Composition;

namespace Microsoft.VisualStudio.Templates.Editorconfig.Command.Commands;

[Export(typeof(INodeExtender))]
internal class AddEditorConfigFileCommandProvider : INodeExtender
{
private IWorkspaceCommandHandler _handler = new AddEditorConfigFileCommandHandler();

public IChildrenSource? ProvideChildren(WorkspaceVisualNodeBase parentNode) => null;

public IWorkspaceCommandHandler? ProvideCommandHandler(WorkspaceVisualNodeBase parentNode)
=> parentNode is IFolderNode ? _handler : null;
}
57 changes: 57 additions & 0 deletions src/VisualStudio/EditorConfig/Command/Commands/CommandBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Logging.Kinds;
using System;
using System.ComponentModel.Design;
using System.Threading.Tasks;
using static Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Logging.Logger;

namespace Microsoft.VisualStudio.Templates.Editorconfig.Command.Commands;

internal abstract class CommandBase
{
public static async Task<T> InitializeAsync<T>(AsyncPackage package)
where T : CommandBase, new()
{
T command = new();

command.Command = new OleMenuCommand(command.Execute, command.Id);
command.Package = package;
await package.JoinableTaskFactory.SwitchToMainThreadAsync(package.DisposalToken);
IMenuCommandService obj = (IMenuCommandService)await package.GetServiceAsync(typeof(IMenuCommandService));
Assumes.Present(obj);
Assert(obj is not null, "unable to get the menu command service");
if (obj is not null)
{
obj.AddCommand(command.Command);
LogEvent(EventId.CommandRegistered);
}
return command;
}

public OleMenuCommand? Command { get; protected set; }

public AsyncPackage? Package { get; protected set; }

private void Execute(object? sender, EventArgs e)
{
EventArgs e2 = e;
Package?.JoinableTaskFactory.RunAsync(async delegate
{
try
{
await ExecuteAsync((OleMenuCmdEventArgs)e2);
}
catch (Exception ex)
{
LogException(ex, "Error executing command");
throw;
}
}).FileAndForget("AddEditorConfigFileCommand");
}

protected abstract CommandID Id { get; }

protected abstract Task ExecuteAsync(OleMenuCmdEventArgs e);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Workspace.VSIntegration.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;

namespace Microsoft.VisualStudio.Templates.Editorconfig.Command.Commands;

internal abstract class CommandHandlerBase : IWorkspaceCommandHandler
{
public virtual int Priority => 100;
public virtual bool IgnoreOnMultiselect => true;

protected abstract CommandID Id { get; }

protected abstract bool QueryStatus(List<WorkspaceVisualNodeBase> selection);
protected abstract bool Execute(List<WorkspaceVisualNodeBase> selection);

public int Exec(List<WorkspaceVisualNodeBase> selection, Guid cmdGroup, uint cmdId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
{
ThreadHelper.ThrowIfNotOnUIThread();

if (IsSupportedCommand(cmdGroup, cmdId) && Execute(selection))
{
return VSConstants.S_OK;
}

return (int)Constants.OLECMDERR_E_NOTSUPPORTED;
}

public bool QueryStatus(List<WorkspaceVisualNodeBase> selection, Guid cmdGroup, uint cmdId, ref uint cmdf, ref string? customTitle)
{
if (IsSupportedCommand(cmdGroup, cmdId))
{
if (QueryStatus(selection))
{
cmdf = (uint)(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED);
}
else
{
cmdf = (uint)OLECMDF.OLECMDF_INVISIBLE;
}

return true;
}

return false;
}

private bool IsSupportedCommand(Guid cmdGroup, uint cmdId)
=> cmdGroup == Id.Guid && cmdId == Id.ID;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Templates.Editorconfig.Command.Commands;
using Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Logging.Kinds;
using System;
using System.Runtime.InteropServices;
using System.Threading;
using static Microsoft.VisualStudio.Templates.Editorconfig.Wizard.Logging.Logger;
using Task = System.Threading.Tasks.Task;

namespace Microsoft.VisualStudio.Templates.Editorconfig.Command;

[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[ProvideMenuResource("Menus.ctmenu", 1)]
[Guid(PackageGuids.AddEditorConfigString)]
public sealed class EditorconfigCommandPackage : AsyncPackage
{
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
using var _ = LogOperation(OperationId.InitializePackage);
await CommandBase.InitializeAsync<AddEditorConfigFileCommand>(this);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.-->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<IsTestProject>false</IsTestProject>
<Nullable>enable</Nullable>
</PropertyGroup>

<!-- VSIX Properties -->
<PropertyGroup>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
<EnableDefaultItems>true</EnableDefaultItems>
<ExtensionInstallationFolder>Microsoft\Editorconfig\Command</ExtensionInstallationFolder>
<ExtensionInstallationRoot>CommonExtensions</ExtensionInstallationRoot>
<GeneratePkgDefFile>true</GeneratePkgDefFile>
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
<Ngen>false</Ngen>
<SetupProductArch>Neutral</SetupProductArch>
<UseCodebase>true</UseCodebase>
<VisualStudioInsertionComponent>Templates.Editorconfig.Command</VisualStudioInsertionComponent>
</PropertyGroup>

<ItemGroup>
<VSCTCompile Include="VSCommandTable.vsct">
<ResourceName>Menus.ctmenu</ResourceName>
<SubType>Designer</SubType>
</VSCTCompile>
</ItemGroup>

<ItemGroup Label="PkgDef">
<PkgDefPackageRegistration Include="{57a6a527-1255-45c4-bcdb-6a4f50b73b3e}" Name="EditorconfigCommandPackage" Class="Microsoft.VisualStudio.Templates.Editorconfig.Command.EditorconfigCommandPackage" AllowsBackgroundLoad="true" />
<None Include="PackageRegistration.pkgdef" PkgDefEntry="FileContent" />
<None Include="source.extension.vsixmanifest" />
</ItemGroup>

<!-- Project References -->
<ItemGroup>
<ProjectReference Include="..\Wizard\Microsoft.VisualStudio.Templates.Editorconfig.Wizard.csproj">
<Name>Microsoft.VisualStudio.Templates.Editorconfig.Wizard</Name>
<IncludeOutputGroupsInVSIX>BuiltProjectOutputGroup;GetCopyToOutputDirectoryItems;SatelliteDllsProjectOutputGroup</IncludeOutputGroupsInVSIX>
<IncludeOutputGroupsInVSIXLocalOnly>DebugSymbolsProjectOutputGroup%3b</IncludeOutputGroupsInVSIXLocalOnly>
<ForceIncludeInVSIX>true</ForceIncludeInVSIX>
</ProjectReference>
</ItemGroup>

<!-- Package References -->
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.SDK" />
<PackageReference Include="Microsoft.VisualStudio.Workspace.VSIntegration" />
<PackageReference Include="Microsoft.VisualStudio.Telemetry" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[$RootKey$\Menus]
"{57a6a527-1255-45c4-bcdb-6a4f50b73b3e}"=", Menus.ctmenu, 1"
21 changes: 21 additions & 0 deletions src/VisualStudio/EditorConfig/Command/VSCommandTable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using System;

namespace Microsoft.VisualStudio.Templates.Editorconfig.Command;

internal sealed partial class PackageGuids
{
public const string AddEditorConfigString = "57a6a527-1255-45c4-bcdb-6a4f50b73b3e";
public static Guid AddEditorConfig = new Guid(AddEditorConfigString);
public const string AddEditorConfigCmdSetString = "713dfda7-0c2f-41ee-8326-54895666044a";
public static readonly Guid AddEditorConfigCmdSet = new(AddEditorConfigCmdSetString);
}

public static class PackageIds
{
public const int AddGroup = 0x0001;
public const int AddGroupAnyCode = 0x0002;
public const int AddEditorConfigFileCommand = 0x0200;
public const int AddEditorConfigFileAnyCodeCommand = 0x0201;
}
Loading
Loading