I've been running into an issue with Visual Studio 2017 where a T4 template that is generating a bunch of C# classes from metadata is auto formatting the files based on the settings in Visual Studio's C# formatting options. I have changed these options and verified that the changes are reflected in the generated code. Basically what is happening is the T4 code generation completes and then Visual Studio begins to open every single file that was just generated and format it.
I've turned off formatting for the C# language in Tools and Options and disabled .editorconfig files just in case it was picking up one of those, but the template generation seems to ignore this. The problem is that these T4 templates generate ~2000 files which are then formatted which causes TFS to check out the file and eventually crashes visual studio about halfway through the formatting. Is there an option somewhere I'm missing to turn off formatting for generated code? This was not an issue prior to our recent upgrade to VS2017.
The default setting for Visual Studio 2017 is that it doesn't do anything to template files on the onset, so in order for this to happen it should be something you've added to your VS environment. Few things to check...
Any Visual Studio extensions or features. T4 is not well supported so a lot of the extensions and features out there have bugs in them. It maybe that the software provider hasn't thought of your problem yet and you should raise a bug with them. If your using an extension or feature to assist in your software development of T4 then try a different one. Additionally extensions or features not related to T4 also format files. An examples are Productivity Power Tools or Resharper
Under the properties of your template files check the Custom Tool value. It may not seem like the obvious choice, but occasionally if this is not set to TextTemplatingFileGenerator or TextTemplatingFilePreprocessor, you need know why it's not set that way. There might be a perfectly good reason for why its set differently, just so long as you know what that reason is
Normally templates use the *.tt extension, however there are many different acceptable extensions that suit different occasions. Make sure the extension isn't named the same as an existing extension, that formats files in its own way
If the features for C# are off, you might want to consider turning off all formatting features one by one incase the templates files are being considered as part of a different language or under a different option. Start with Tools > Options > Text Editor > Basic > Advanced > Pretty listing as an example. That may give you a clue as to where the setting is being affected.
HTH
I used to code on Visual Studio Code. Now, i'm trying to learn how to code on Visual Studio 2017 as it will be more beneficial for me. So far, it's so good.
But there is one thing which i miss on VS which is, in VSC, there was a neat extension, called Path Intellisense which autocompleted (or showed suggestions for) ./../file style file-paths. While coding in javascript (ExpressJS to be exact) i got no suggestions for file path autocomplete. Also, i didnt get any extensions to do so.
Those dot style file paths confuse me and i would really like an extension, or a workaround, in VS to help me with that. Are there any extensions for this?
E.g.
I really want to use this plugin. But once I do "Export as Snippet", I can't see a new tab where I can manage the snippet, set the Shourcut and such (as shown in the video). I only see this popup:
What is going on? Add new item?
I've updated to the last (update 3) version of Visual Studio 2015, and I've Snippet Designer 1.6.2.
UPDATE - WORKAROUND, AND POSSIBLE FUTURE FIX
I have tested Snippet Designer with Web Forms (Web Site Projects), and it does not work as described in the video, i.e. with the snippet file being automatically created.
However, it is possible to continue working with Snippet Designer, by selecting the Project Item named Code Snippet, as follows:
Create or open a Web Site project.
Select the text you wish to make a Snippet. Right click and select Export as Snippet.
In the New File Dialog window that opens, you need to locate the File Type Code Snippet. The easiest way in a long list of installed File Templates is to use the search feature, typing snippet.
Click Add. The file will be added to your project, and now Snippet Designer will activate, and function as normal.
NOTE: This is creating a default C# Code Snippet file, not the snippet file that is included within the Snippet Designer .vsix archive; it makes no difference as both files are empty, and Snippet Designer has its own code for building the contents of a snippet file according to the relevant XML schema, as specified by Microsoft.
A possible reason why Snippet Designer does not automatically create the snippet file itself, as it does with other projects, is that Web Site projects use a different approach to project metadata; for example, they do not have a .csproj file, which is typically used to list the files within a project.
It could also be that the code creating the snippet file asks Visual Studio, via Automation, to create a new instance of the snippet file Item Template; on a default Visual Studio 2015 installation, the listing of available Item Templates for a Web Site Project are located in:
C:\Program Files (x86)\Microsoft Visual Studio
14.0\Web\WebNewFileItems\NewFileItems.vsdir
Snippet Designer also includes a .vsdir file that has an entry for its own bundled snippet file, the source can be viewed here:
https://github.com/mmanela/SnippetDesigner/blob/master/src/SnippetDesigner/Templates/SnippetFile.vsdir
I would suggest the author of Snippet Designer investigate if the entry here is the source of the problem.
Microsoft provide documentation for the metadata contained in .vsdir files here: Template Directory Description (.Vsdir) Files
I do actually recommend a different product. My original answer continues below:
CURRENT SITUATION
As has been documented on the Snippet Designer GitHub Issue Tracker, there are issues with specific project types not being recognised, and therefore features not available.
The last commit to the Snippet Designer GitHub project was 1 year ago (November 2015); in view of the number of unresolved issues and lack of development, I would suggest a known working open source alternative.
WORKING ALTERNATIVE
Code Snippet Studio is another free, open source project for creating, editing and managing Snippets that fully supports Visual Studio 2015 (including Update 3), and which is actively developed and released:
Code Snippet Studio
Code Snippet Studio is an extension for Visual Studio 2015 that makes it easy to create, edit, package, and share IntelliSense code snippets for Visual Studio 2015 and Visual Studio Code. For C# and Visual Basic snippets, it also provides live Roslyn code analysis as you type to immediately detect code issues.
Note that multiple languages, including C#, VB, SQL, HTML, JavaScript are supported, among others. The image below shows VB editing.
Code Snippet Studio runs as either a Tool Window in Visual Studio 2015, or, as a standalone application (which personally I find ideal for working alongside Visual Studio Code on a laptop, or to make quick updates to my snippet packages).
Features include Roslyn based intellisense and analysis while editing snippets, specification of namespaces that need to be imported to support the Snippet, the ability to export to Visual Studio or Visual Studio Code, and optionally, create a VSIX file for installation on multiple machines.
FURTHER INFORMATION
For more information, the following links are useful:
Channel 9 - A Look Behind Code Snippet Studio (with Video)
GitHub Project
Getting started Guide
Channel9 - One code snippet at a time [and more] with the Code Snippet Studio
This is a known problem, see github issues 57, 70, 84, 109. I can only suggest that you persuade addon author to fix it, or fix it yourself :)
We need to localize an app that has hard coded strings across aspx and c# files.
This is a common need, so we expected to find tooling.
We tried resharper, but it turns out that for aspx files, this feature is essentially nonexistent.
What is the path forward? (initially 60 aspx files, ultimately 200+)
I should add that we reviewed all known tools (below). In every case, at least one of the below is true:
Does not work at all in visual studio 2015
crashes right and left
does not support aspx (mostly support .cs files only)
https://visuallocalizer.codeplex.com/
http://www.lingobit.com/extractor/c_sharp_extract_hardcoded_string.html
https://visualstudiogallery.msdn.microsoft.com/39ae29d3-81e1-43d4-9c48-fc9644869d84
Visual Studio - Tool to replace hard coded strings with resources
Find all source hardcoded strings
The best solution we have found so far is: Jinnee.Prelude 2015
https://visualstudiogallery.msdn.microsoft.com/e71acd60-0f16-4adf-b398-18c4fa210916
Gives us localization in C# and static strings in ASPX. But still need to extract inline strings from ASPX by hand.
It crashed VS a couple of times, but VS is fast to restart (thanks to not having resharper installed). Overall it is a win. (Wish we had sources so we could enhance it further!)
I am working on a big solution that contains a mix of C# and C++ code using Visual Studio 2012 Professional with the latest Resharper plugin.
I obtain a fresh copy of the entire solution from source control.
As expected, Intellisense places its curly red lines under many types and fields in C++ code before I compile my Solution for the first time. However now these squiggly lines do not disappear even after (successfully) compiling the entire solution.
I get 100+ Intellisense errors saying "Intellisense: cannot open source file .tlh
But these files definitely exist at the given location and VS has full access rights to them as I start it with elevated rights..
I am even able to jump into the namespaces, declarations or whatever with the red lines underneath so the code definitely exists.
How do I make Intellisense worke again and make these annoying lines disappear?