Page MenuHomePhabricator

Warning-free clang-format plugin install for VS 15.0
ClosedPublic

Authored by hstefan on Apr 5 2017, 8:23 PM.

Details

Summary

With the new release os VS, it's required that all plugins migrate the new VSIX manifest format. The new format is backwards compatible with all versions newer that Visual Studio 2012, so this migration effectively drops support for older versions of the IDE.

It's also required that these new extensions are built with Visual Studio 2017, so unfortunately it was necessary to migrate the project and solution. Also removed COM references to EnvDTE and Microsoft.VisualStudio.TextManager.Interop from the csproj, as they seem to both be unnecessary and would trigger build warnings because of changes to GAC.

Diff Detail

Repository
rL LLVM

Event Timeline

hstefan created this revision.Apr 5 2017, 8:23 PM
hstefan retitled this revision from Waning-free clang-format plugin install for VS 15.0 to Warning-free clang-format plugin install for VS 15.0.
hans edited edge metadata.Apr 6 2017, 1:48 PM

Thanks! I'll need a few days to get VS2017 so I can try this out.

hans added a comment.Apr 12 2017, 2:10 PM

Sorry for the delay; I finally got VS2017 installed.

I got these build errors when trying your patch directly:

Microsoft Visual Studio 2017 Version 15.0.26403.3.
Copyright (C) Microsoft Corp. All rights reserved.
1>------ Build started: Project: ClangFormat, Configuration: Release Any CPU ---
---
1>D:\src\llvm\tools\clang\tools\clang-format-vs\ClangFormat\ClangFormatPackage.c
s(15,7,15,13): error CS0246: The type or namespace name 'EnvDTE' could not be fo
und (are you missing a using directive or an assembly reference?)
1>D:\src\llvm\tools\clang\tools\clang-format-vs\ClangFormat\RunningDocTableEvent
sDispatcher.cs(1,7,1,13): error CS0246: The type or namespace name 'EnvDTE' coul
d not be found (are you missing a using directive or an assembly reference?)
1>D:\src\llvm\tools\clang\tools\clang-format-vs\ClangFormat\Vsix.cs(1,7,1,13): e
rror CS0246: The type or namespace name 'EnvDTE' could not be found (are you mis
sing a using directive or an assembly reference?)
1>D:\src\llvm\tools\clang\tools\clang-format-vs\ClangFormat\RunningDocTableEvent
sDispatcher.cs(73,17,73,25): error CS0246: The type or namespace name 'Document'
 could not be found (are you missing a using directive or an assembly reference?
)
1>D:\src\llvm\tools\clang\tools\clang-format-vs\ClangFormat\Vsix.cs(30,44,30,52)
: error CS0246: The type or namespace name 'Document' could not be found (are yo
u missing a using directive or an assembly reference?)
1>D:\src\llvm\tools\clang\tools\clang-format-vs\ClangFormat\Vsix.cs(37,52,37,60)
: error CS0246: The type or namespace name 'Document' could not be found (are yo
u missing a using directive or an assembly reference?)
1>D:\src\llvm\tools\clang\tools\clang-format-vs\ClangFormat\RunningDocTableEvent
sDispatcher.cs(13,17,13,20): error CS0246: The type or namespace name 'DTE' coul
d not be found (are you missing a using directive or an assembly reference?)
1>D:\src\llvm\tools\clang\tools\clang-format-vs\ClangFormat\RunningDocTableEvent
sDispatcher.cs(15,64,15,72): error CS0246: The type or namespace name 'Document'
 could not be found (are you missing a using directive or an assembly reference?
)
1>D:\src\llvm\tools\clang\tools\clang-format-vs\ClangFormat\ClangFormatPackage.c
s(266,50,266,58): error CS0246: The type or namespace name 'Document' could not
be found (are you missing a using directive or an assembly reference?)
1>D:\src\llvm\tools\clang\tools\clang-format-vs\ClangFormat\ClangFormatPackage.c
s(316,37,316,45): error CS0246: The type or namespace name 'Document' could not
be found (are you missing a using directive or an assembly reference?)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
ninja: build stopped: subcommand failed.

But adding references to those assemblies made it go away:

diff --git a/tools/clang-format-vs/ClangFormat/ClangFormat.csproj b/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
index bb3cd4e..71f4b3d 100644
--- a/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
+++ b/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
@@ -58,6 +58,12 @@
     <Prefer32Bit>false</Prefer32Bit>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="envdte, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">^M
+      <EmbedInteropTypes>True</EmbedInteropTypes>^M
+    </Reference>^M
+    <Reference Include="envdte80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">^M
+      <EmbedInteropTypes>True</EmbedInteropTypes>^M
+    </Reference>^M
     <Reference Include="Microsoft.CSharp" />
     <Reference Include="Microsoft.VisualStudio.CoreUtility, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
       <HintPath>..\packages\VSSDK.CoreUtility.10.0.4\lib\net40\Microsoft.VisualStudio.CoreUtility.dll</HintPath>

Is there something different with my machine, or should we just add that to your patch?

I verified that the plugin installs and works on my machine with VS 2012, 2013, 2015 and 2017, which is pretty awesome :-)

Many thanks for working on this!

tools/clang-format-vs/source.extension.vsixmanifest.in
4

Is this just a random UUID, or does it have some significance?

17

What's CoreEditor? 15.0 makes it sound like something from VS2017?

Dealing with EnvDTE has been a bit of an annoyance in my computer too, but In my case I ran into this https://developercommunity.visualstudio.com/content/problem/15434/cannot-find-wrapper-assembly-for-type-library-envd.html. I didn't have any luck with the solution proposed on that question, but I believe its results would be similar to what you ended up doing yourself, so I think it would be fine to add that to the original patch. Do I need to submit a new patch with those changes included too?

In case you're interested, my answers to your comments were based mainly on what I've found in http://www.visualstudioextensibility.com/2017/01/10/its-time-to-change-the-vsix-manifest-of-your-extension-to-v3-for-visual-studio-2017-compatibility/ and http://www.visualstudioextensibility.com/2016/11/23/some-implications-of-the-new-modular-setup-of-visual-studio-2017-for-vsx-developers/

tools/clang-format-vs/source.extension.vsixmanifest.in
4

I reused the same UUID we had in the previous manifest (Identifier id attribute), I just converted it to the new format.

17

Since VS2017 extensions are expected to declare which minimal "modules" of the IDE they need. CoreEditor is the most basic one, which seems appropriate for this plugin, the version is indeed related to the "VS 15.0".

hstefan updated this revision to Diff 95079.Apr 12 2017, 10:09 PM

Adding the changes suggested on https://reviews.llvm.org/D31740#725320. I verified that this still builds and works well on my computer, so if it fixes the errors in the original diff I think it's an ok change to introduce.

hans accepted this revision.Apr 13 2017, 10:12 AM

LGTM with the version attribute for Microsoft.VisualStudio.Component.CoreEditor changed to 11.0 or higher.

Do you have commit access or would you like me to commit for you?

tools/clang-format-vs/source.extension.vsixmanifest.in
17

I was worried that the 15.0 means this depends on some component of VS2017.

I tried installing the plugin for VS2013 on a machine that has never had VS2017 installed. The plugin did install and show up in "Tools > Extensions and Updates" but the actual commands to format code did not show up in the Tools menu!

I changed the Version attribute to "[11.0,)" instead, and then it worked.

This revision is now accepted and ready to land.Apr 13 2017, 10:12 AM

No, I don't have commit access (though I might request it if I manage to actually continue collaborating).

Thanks for the notes on the 11.0 vs 15.0 issue, I wrongly assumed the prerequisites session would be entirely ignored by older versions.

This revision was automatically updated to reflect the committed changes.