visual-studio-2015

Implement interface with Disposable Pattern

折月煮酒 提交于 2021-02-08 05:16:31
问题 Note: This is a Visual Studio 2015 feature only, as far as I know... How can I edit the Implement interface with Disposable Pattern option? This is NOT a question on how to Implement the Dispose Pattern and its variations, but how to edit the option "Implement interface with Disposable Pattern" I would like to remove some comments and add some code on the Disposable Pattern, but I want it to be saved and every time I click " Implement interface with Disposable Pattern ", it implements my code

How can I find previous usages of a variable using Roslyn?

本小妞迷上赌 提交于 2021-02-08 02:57:32
问题 I'm writing a Rosyln analyser/analyzer. It checks to ensure that a method is called before accessing another (potentially dangerous) method on a type. To show what I mean, here's some bad code that I want to analyse and fail on: private void myMethod() { var myThing = new MyThing(); myThing.Value = null; string value = myThing.GetValue(); // code blows up here as the internal value is null } Here's code that's OK because it calls a method that says whether it's null: private void myMethod() {

Do not copy SASS / LESS file when using Web Publish

大兔子大兔子 提交于 2021-02-08 01:48:05
问题 When publishing a Web Application (MVC in my case) via File System in Web Publish setting, most of the *.scss & *.less files get deployed as well. How do I configure a Visual Studio project so that it does not deploy these files? 回答1: I believe setting "Build action" to "None" and "Copy to output directory" to "Never" should work. You can do it in property window of the file. Right click the file in solution explorer and click properties 回答2: Visual Studio deploys only those files that are

Avoid formatting code on paste Visual Studio 2015

妖精的绣舞 提交于 2021-02-07 14:33:21
问题 When I copy and paste the code with Visual Studio, it will auto-format the pasted code (for example, it removes some extra spaces that I have intentionally added for clarity) I just want that the code is pasted as I copied it, just like a normal text editor does. What I copy it's what I paste :) Is it possible to just disable the auto-format on paste? Thanks! 回答1: Alternatively, to paste text from the clipboard without reformatting applicable to any language, you can use the following C#

Avoid formatting code on paste Visual Studio 2015

孤者浪人 提交于 2021-02-07 14:32:23
问题 When I copy and paste the code with Visual Studio, it will auto-format the pasted code (for example, it removes some extra spaces that I have intentionally added for clarity) I just want that the code is pasted as I copied it, just like a normal text editor does. What I copy it's what I paste :) Is it possible to just disable the auto-format on paste? Thanks! 回答1: Alternatively, to paste text from the clipboard without reformatting applicable to any language, you can use the following C#

Acessing currently opened solution in a vsix project

你离开我真会死。 提交于 2021-02-07 12:54:17
问题 I want to access the path to currently open solution in Visual Studio from a vsix project. How can I get that? This thread tells if a solution is open or not but gives nothing about the path of the opened solution 回答1: I use this: public string GetInitialFolder(DTE dte) { if (!dte.Solution.IsOpen) return null; return System.IO.Path.GetDirectoryName(dte.Solution.FullName); } But expect it to error, sometimes it cannot return a path! 回答2: I would suggest to avoid EnvDTE as much as possible when

Unsupported This version of Visual Studio is unable to open the following projects

笑着哭i 提交于 2021-02-07 11:44:08
问题 I'm getting error like this after updating sql server to 2016. I have opened the project in VS2015 & while rebuilding Database project I'm getting error like below: Unsupported This version of Visual Studio is unable to open the following projects. The project types may not be installed or this version of Visual Studio may not support them. For more information on enabling these project types or otherwise migrating your assets, please see the details in the "Migration Report" displayed after

VS 2015 Update 2 - Variable does not exist when debugging, why?

只愿长相守 提交于 2021-02-07 11:32:25
问题 I'm using VS 2015 Update 2 with an asp.net 5 web project configured for debug mode. When I run the project with F5 to debug it and hit a break point, some variables can not be observed in the watch window even when they are in scope. Further, if I hover over such variables no value is displayed. If I use the same visual studio to create an empty web project and add a webform and place the code in the load method, the debugger works fine. That is to say, I can see the variables in the watch

Code Analysis Warning CA2213 - Call Dispose() on IDisposable backing field

馋奶兔 提交于 2021-02-07 11:18:23
问题 Wanted to post this, even though I figured it out as I was writing the question. Will post answer below. Getting the following warning with VS Code Analysis: Warning CA2213 'DBConn' contains field 'DBConn.k__BackingField' that is of IDisposable type: 'SqlConnection'. Change the Dispose method on 'DBConn' to call Dispose or Close on this field. But my code does call Dispose() on the DBConn property. Does it not on the backing field? I have other instances like this - where I am disposing of

How do I restore the default VS toolbar configuration?

随声附和 提交于 2021-02-07 11:17:41
问题 How do I restore the default VS toolbar configuration? By that, I mean: the set and location of enabled toolbars the set and order of items on each toolbar I know how to reset the set and order of items on a given toolbar , so if I knew which are the default-enabled toolbars (and their location) then I would be able to enable and reset each of them one by one. I don't want to reset all VS settings. 回答1: Tools > Import and Export Settings... > Import selected environment settings > Choose a