Posts

Instruct GIT not to track a specific file

In scenarios like you have a configuration file in  a remote repo for the production environment, and you don’t want to commit the changes to this configuration file made from local.  How do you instruct git to do not track the local changes? --skip-worktree is what you need. git update-index --skip-worktree <filepath/file_name> After index update git won't show you the file in working tree. If you want to track the changes update-index as  git update-index --no-skip-worktree <filepath/file_name>

Update WPF Interaction Triggers in from .Net Framework 4.8 to .Net 5

  When migrating the Visual Studio projects from .Net Framework 4.8 to .Net 5, you may encounter   in the following error regarding Interaction.Triggers .   Error      XDG0008             The name "Interaction" does not exist in the namespace "http://schemas.microsoft.com/xaml/behaviors".   The one solution to fix it is to install “ Microsoft.Xaml.Behaviors.Wpf ” from Nuget And update the namespace ( if needed) xmlns : i ="http://schemas.microsoft.com/expression/2010/interactivity" to              xmlns:i ="http://schemas.microsoft.com/xaml/behaviors"

[Snippet] Add/Remove an Assembly to/from the Global Assembly Cache using C#.Net

  Code snippets to add remove an assembly from GAC -  Add reference to - System.EnterpriseServices using System.EnterpriseServices.Internal; var path = "the absolute path of assembly";  Publish publish = new Publish();  publish.GacInstall(path);  publish.GacRemove(path); Reference: https://docs.microsoft.com/en-us/dotnet/framework/app-domains/install-assembly-into-gac#global-assembly-cache-tool https://docs.microsoft.com/en-us/dotnet/framework/app-domains/how-to-remove-an-assembly-from-the-gac

[Code Snippet] : Connect to Sql Server from ArcObject

 using System; using ESRI.ArcGIS.DataSourcesFile; using ESRI.ArcGIS.esriSystem; using ESRI.ArcGIS.Geodatabase; namespace MyNamespace {   class MyProgram   {     private static LicenseInitializer _licenseInitializer = new LicenseInitializer();     [STAThread()]     static void Main(string[] args)     {       _licenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB },                                                    new esriLicenseExtensionCode[] { });       Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SqlWorkspaceFactory");       IPropertySet propertySet = new PropertySetClass();       propertySet.SetProperty("SERVER", " servername ");       ...

[Code Snippet] Assert.Throws on Exception and Derived Type Nunit

 Code snippet for asserting throw in ArgumentException and its derived types(such as ArgumentNullException) in Nunit -  public void Test(){ Assert.Throws(Is.InstanceOf<ArgumentException>(), () =>{      //SUT code }); }

[Code snippet] How to set value of private variable in Unit Test Using Reflection ?

A sample example to set private variable to true from unit test class in C#.Net //TestService.cs public class TestService {         private bool _isInitialized = false; } //TestServiceUnitTest.cs using System.Reflection; public class TestServiceUnitTest {           private TestService _testService ;                    [TestInitalize]           private void testInitalize()          {             _testService = new TestService();          }                  [TestMethod]          Private void SetInitializeToTrue()          {                          FieldInfo field = typeof(TestService).GetField(" _isInitializ...

[Code Snippet] Assert Exception in private methods using PrivateObject

NON ASYNC Method Method.cs private MyMethod(object value1) {       if(value1 == null)       {            throw new ArgumentNullException(nameof(MyMethod));       } } Test.Cs [TestMethod] public void MyMethod_Throws_Verify() {          PrivateObject po = new PrivateObject(new Method()) TargetInvocationException exception = Assert.ThrowsException<TargetInvocationException>(() =>                     privateObject.Invoke("MyMethod", new object[] { null }));             Assert.AreEqual(typeof(ArgumentNullException), exception.InnerException.GetType());         }