Search This Blog

Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Monday, August 31, 2020

Creating Unit Test Fact method code snippet in Visual Studio

Save the following xml file with the .snippet extension.

Afterwards, load it into the Code Snippet Manager in Visual Studio via 

Tools -> Code Snippet Manager -> Import

That's it. Type tt + Tab and the code block between CDATA[...] is inserted.


 <?xml version="1.0" encoding="utf-8"?>

<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">

<CodeSnippet Format="1.0.0">

<Header>

<Title>UT Fact</Title>

<Author>AYK</Author>

<Description>Add Unit Test Fact</Description>

<Shortcut>tt</Shortcut>

</Header>

<Snippet>

<Code Language="CSharp">

<![CDATA[

[Fact]

public async Task ObjectBeingTested_Action_ExpectedResult()

{

                                        //arrange

                                        //act

                                        //assert

}]]>

</Code>

</Snippet>

</CodeSnippet>

</CodeSnippets>

Monday, August 24, 2020

Auto generate class diagram in visual studio 2019

 From StackOverflow:

In Visual Studio 2019, dragging the whole project to an empty class diagram (add new item -> class diagram) will do the job.

Make sure you have the Visual Studio Class Designer component installed.


Monday, October 29, 2018

Useful debugging tips for Visual Studio

https://blogs.msdn.microsoft.com/visualstudio/2017/09/18/7-more-lesser-known-debugging-tactics-for-visual-studio/

Tuesday, June 26, 2018

MSDN general guidelines for debugging with Visual Studio

Taken from https://referencesource.microsoft.com/setup.html

         You can configure Visual Studio to automatically step over system, framework, and other non-user calls and collapse those calls in the call stack window. The feature that enables or disables this behavior is called Just My Code. This topic describes how to use Just My Code in C#, Visual Basic, C++, and JavaScript projects.
          To debug .NET Framework source, you must have access to debugging symbols for the code. You also need to enable stepping into .NET Framework source.

          You can enable .NET Framework stepping and symbol downloading in the Options dialog box. When you enable symbol downloading, you can choose to download symbols immediately or just enable the option for later downloading. If you do not download the symbols immediately, symbols will be downloaded the next time that you start debugging your application. You also can do a manual download from the Modules window or the Call Stack window.

  • Require Source Files to Exactly Match The Original Version

Sunday, February 4, 2018

Adding files and folders to a click once installation

Having trouble in adding specific files to your click once installation ? Morover, you want them to be placed under a specific folder ?

Here are the steps I followed that finally did it:

  1. You need to create the folder/file structure just like you want it to exist in your installation - in your visual studio project. For example, I needed two folders - x86 and x64, and the same  SQLite.Interop.dll under both
  2. Right click in your project, go to the Publish tab, then click in Application Files. Scroll down (they should be showing as the last items) to your added files, and make sure you change the Publish Status from Include (Auto) to Include. 
Should work now.



      

Saturday, January 20, 2018

Exe icon is missing in custom Build Configurations after Visual Studio build

If you add custom build configurations to your solution, make sure you manually add, for all of them, the ApplicationIcon element with the proper .ico file in the .csproj file of the main project.

  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Development|x86'">
    <ApplicationIcon>MyIcon.ico</ApplicationIcon>
  </PropertyGroup>

Thursday, May 4, 2017

Building VS projects via command line

An important thing to keep in mind when running msbuild providing properties (in the form of /p:[Key]=[Value]) (for instance, a list of properties useful in building clickonce applications can be found here) is (taken from MSDN):
Global properties are properties that are set by using the /property switch on the command line, or properties that are set by the integrated development environment (IDE) before a project is built. These global properties are applied to all projects that are built by using this Engine.
In other words, if you build a solution with 7 projects (1 start-up plus and 6, say, class libraries), and you provide the AssemblyName parameter like /p:AssemblyName=MyAssembly, you will end up with 7 assemblies with the same name, one with an EXE extension (depending on your project template) and the others with DLL. I, for instance, wanted to rename the final EXE file. Doing this using the approach above did not work for me because of the DLL name conflicts. My scenario uses Jenkins as the CI tool, and I ended up adding a Windows Batch command at the end of the process that renames the $PROJECT_NAME exe only.

Wednesday, February 15, 2017

Why Edit and Continue is not working even though it is marked in Visual Studio ?

Because it is supported only in projects that has framework versions greater or equal to 4.5.1 (from here).

AND - your scenario is likely one of the following:


Sunday, December 18, 2016

Reset Visual Studio "Look at these file types" value

private static void Main(string[] args)
{
    RegistryKey regKey = null;

    try
    {
        //HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0\Find
        regKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\VisualStudio\14.0\Find"true);

        var filters = regKey.GetValueNames().Where(v => v.StartsWith("Filter"));
        foreach (var filter in filters)
        {
            regKey.SetValue(filter, string.Empty);
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine("Registry clear for filter keys failed. {0}", ex.Message);
        return;
    }
}

Tuesday, November 22, 2016

Find in Visual Studio Find Results (further search)

I was wondering if it was possible to further search the results of a Find Results window in Visual Studio. I googled it but did not arrive to any relevant answer.

I then played a bit with it and ended up figuring out that it is possible - it is built in, and it's quite simple: just click CTRL + F inside the Find Results window.



Monday, September 26, 2016

Permanently run Visual Studio in admin mode


Right click in your VS shortcut -> Properties -> Advanced -> Run as administrator.


Wednesday, August 17, 2016

Visual Studio Web Development Extensions

http://webtooling.visualstudio.com/extensions/web-development

Going up one level, you get into http://webtooling.visualstudio.com, that overviews what visual studio offers in covering the technologies being used today.

P.S.: PowerTools has historically given me freezing problems, making it not an option.

P.S. II: The power tools issue mentioned above is gone after moving to Windows 10 (recommend, by the way, seems to give benefits on many other fronts, like Xamarin development, for example).