Showing posts with label VisualStudio. Show all posts
Showing posts with label VisualStudio. Show all posts

Wednesday, 23 June 2021

Merge Specific Changeset in Azure Repos or Git with Visual Studio Code

To get a specific checked in changeset item in Azure Repos (Git) in Visual Studio Code, we use git cherry-pick command. It can be a changeset belong to a different branch. There is Merge Branch menu, but this will get and merge all the new changesets into our working branch.

By default when running git cherry-pick command, it will automatically merge and check in the codes in the repository for us. Use -n option to have the codes staged and we can check in manually.

Run in Terminal window:
git cherry-pick -n [commithashcode]

Wednesday, 18 July 2018

Node.js and Proxy Server Issue

Tried to build a new web project in Visual Studio 2017. However it was unsuccessful and I saw the required packages were missing. I tried to do ‘Restore Packages’ again many times but still not good.


Then I tried to check whether Node.js has been installed properly. Found out, nothing wrong with it. I suspected this is because of something wrong with the proxy setting as this happened in a corporate environment.

To see proxy server setting in Node.js, I ran:
npm config get proxy
Turned out that the password used is my old password that was used when I installed Visual Studio. So I updated the setting with:
npm config set proxy http://[DOMAIN]%5C[USERNAME]:[PASSWORD]@[SERVER-ADDRESS]:[PORT-NUMBER]
Then I tested the connectivity to Node.js registry server with:
npm ping
The result displayed was:
Ping error: Error: self signed certificate in certificate chain
npm ERR! code SELF_SIGNED_CERT_IN_CHAIN
npm ERR! self signed certificate in certificate chain
The error indicates there is something wrong with SSL connection. When I checked the ‘strict-ssl’ and ‘registry’ values with ‘npm config list -l’ command, they were ‘true’ and ‘https://registry.npmjs.org/’. So I ran these commands to change the connection to use non secured connection:
npm config set strict-ssl false
npm config set registry http://registry.npmjs.org/
Tried ‘npm ping’ again and the result was ‘Ping success: {}’.

Now, I could restore the missing packages in Visual Studio.

Friday, 23 January 2015

How to Check Objects References in Visual Studio

We can use a tool in Visual Studio when debugging to check whether two objects point to the same instance. First, add the objects/variables that we want to check to Watch list. Right click one of the variables, then select Make Object ID.

After doing this, an ID will be displayed on the Value column in this format '{ID_Number#}'. At the same time, all other objects that point to the same instance will have this displayed on their values as well.

If two or more variables have the same ID number then it means that they point to the same instance.

If we rather would like to check the objects manually, we could use Object.ReferenceEquals(object1, object2) method that will return a boolean value.

Friday, 1 March 2013

Debugging LINQ Query in Visual Studio 2010 with LINQPad

I found out that we can use LINQPad (LINQPad Visualizer) to debug LINQ queries in Visual Studio 2010. To be able to do this we need to:
- install LINQPad

- download LINQPad Visualizer

- copy these files from LINQPad folder (eg. Program Files (x86)\LINQPad4): LINQPad.exe and LINQPad.exe.config
and from the downloaded LINQPad Visualizer folder: linqpadvisualizer.dll, Newtonsoft.Json.dll and Newtonsoft.Json.xml
to Documents\Visual Studio 2010\Visualizers (create the folder if not exists)

- copy LINQPad.exe and LINQPad.exe.config to the same folder as devenv.exe (eg. C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE)

- restart Visual Studio

Then we can put a breakpoint on a LINQ query and start debugging. When we want to inspect a variable, put this on the Name column on Watch window
new System.WeakReference([variable_to_inspect])
then click the magnifier glass icon on the Value column, the visualizer should appear.


Further reading:
https://www.simple-talk.com/dotnet/.net-framework/linq-secrets-revealed-chaining-and-debugging/