A good PR guide
- Pull request for each feature is a minimum when completing a story for the same.
- Assign a reviewer and setup some time with him , and give adequate time to review .
- Allocate adequate time for reviewee as well to address the points raised by PR and fix them in the sprint stories.
- Finally meet once again with reviewer to ‘resolve’ all the feedback given and get approval of the PR.
- Ensure that the code works and is tested before the merge.
- Once the PR is approved , validate the build and static code are successful, before merging and delete your branch to maintain repo hygiene.
- Keep PR’s small, so that the review is quick and feedback will not take much time.Else most of the time if you have a long living branch with lots of files,its very tedious to go throught various features and requirements to understand what was the expected behaviour.
- Give a proper description for each PR, with changes implemented nicely listed.
- Respect the time of both reviewer/reviewee, so that a proper time to fix a time with your reviewer.
- As a reviewer, it’s your responsibility not to hold on to the PR for too long , lest you end up blocking deployment and release.
- Give constructive feedback for each review and not generic statements or mocking .Being rude is not an objective here, even if the code is frustrating to review.
- The reviewer can ask the reviewee questions to understand more on the functionality or context.
- Commented code or temp code should be avoided and maintain coding practices including testing and static analysis.
- Always watch out for sensitive data not being checked into git.Eg config files with password.
- We should always protect the main release branch from being merged directly without a PR process.
TIP: You now have the ability to review/start a PR within Intellij itself.
Guide for a new Repository
- Tag your Git repos along with application name or common theme which is relevant for that repo.Eg you might have several repos related to a proj called MyCart, tagging all the repos with MyCart will help discover them faster .
- Add readme with endpoints and support doc whenever possible.At the minimum each repo should atleast mention the core responsibilities of the repo.
- Enable Branch protection to avert inadvertent pushes.
- Readme updates in case of special needs like building the proj.
- Adding last Build run statuses using urls to you pipeline.
There is no limit on how far we would want to refine our git standards, but i have only concentrated on the min here which are the first 5 points above.
Code Check-in Guidelines
- Before starting any work, take the updated code from git
- Cut a branch name prefixed with feature Eg “feature-” from dev
- this can be tagged to create a build name prefixed with “b” in drone (Example: b54-123e1222)
- test your changes locally
- Once testing is done, create a Pull Request from your feature-* branch to dev
- On merge, this should create a build name prefixed with “dev” in drone(Example: dev64-ff4e1233)
- deploy these “dev*” builds in dev environment
- test your changes in dev environment.
- The last merge happens from dev to master via another Pull Request
- this can create a build name prefixed with “p” in drone(Example: p34-22e6e882)
- deploy these “p*” builds in prod environment
- test your changes in prod env
- Once the changes are deployed to prod, delete the “feature-*” branch
** In some scenarios if you keep a stage branch you will want to merge your changes from dev→ stage before you move to master. This will facilitate a prod like environment for UAT .
Well for starters let me assume you are a poor dev like me and don’t have access to Resharper! Well in case you do they have a lot of these features that are now available free of cost in Productivity Tools in VisualStudioGallery.msdn.microsoft.com.
Let me quickly show you some of the features that stand out pretty instantaneously .
1.PresentOn/Off – type this into the quick launch and lo you get the power of zoomit 🙂
2.You can now edit a project file by right clicking on the project.
3.Browse to definition by pressing on control and left mouse click.
4.Email code snippets by using the same option in context menu.
5.Now you can find duplicate code snippets by selecting the option “Find Matching clones in solution” in context menu.
Also there are other features like Auto Brace Completion,Open Command Prompt and HTML copy.
So go ahead and give it a download!!
Well most often MS doesn’t setup stuff .So you have to do it for yourself.Like for Load testing in VS test cases,
you have to configure the database “LoadTest2010” and the corresponding tables like LoadTestRun,LoadTestCase,…
Well this is how you can do it in case you stuck at it.
Browse to this folder and execute in command line else you can always run the script in Management Studio.
cd “C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE”
SQLCMD /S localhost\sqlserver -i loadtestresultsrepository.sql
Well this one was pretty nasty I must admit.I didn’t know that I would lose some time on this one.And since I did I might as well blog about it.So here goes the problem statement.Have you faced the scenario wherein you had to copy some files under some folder in Unit tests in Visual Studio? This is because the test cases run under a folder called test results and each time you run it creates a new folder for that particular test case. Mind you before I start I must say that I have encountered this on the VS-2010 and not on the nascent versions of Visual Studio viz 2012.So here goes as to what you need to do to achieve the same.
1)First go the TestSettings file in VS 2010 which is directly under solution.
2)Go to Deployment section and check Enable deployment and add the directory that you want to add.
3)Now is the trick part you have to edit the Test Settings file in Xml editor and go the tag under Deployment which has the required DeploymentItem and the attribute outputDirectory as follows.
4)Finally the worst part was now when you run the unit tests you will still now find it added.So to get it in working in VS 2010 you have to select the test list editor under the Test–>Windows menu in Visual Studio IDE.And then select your tests and hit run.Eureka… ooo still not there yet.The directory or file is still not out there!
5)Close your Visual Studio IDE and open it once again.(Age old trick works in the realm of WINDOWS).
So happy testing once again 🙂
I was recently working with xmls and xsd’s and came across this wonderful utility called XSD.exe.Using this you can create classes or xmls from schema’s and viceversa as well.Wonderful aint it?
Generate classes from a given xsd
C:\classfiles>xsd “C:\SampleServices\Item\Lookup.xsd” /classes
For more info go to the path where xsd is(mine is C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools or C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64.This location is for VS2010 as you would have already presumed) in the command prompt is and hit
And did you know you can even generate schema for a type from a dll or exe.. Cool eh?!
There has many a time that i have posted on tools, that makes life so much simpler,in order that we can can have the extra time to fall in love with C#!So many of us hate to see Xml. Lets admit it ,not many are in awe of the beauty called xml and have burnt their fingers and are not comfortable with it.But next time when you hear that you have to create a custom configuration,don’t fear as we have tools in place to handle that.Thanks to the wonderful tool called Configuration Section Designer.I wouldn’t have ventured into it had not i made a silly mistake which took my entire day and i began to question the logic of creating all these with mere hands and why not get it automated?
You can install the Configuration Section Designer from here.Once you download the plug-in and install it ,it fits perfectly well with VS-2008. and VS-2010 folks ,your version is yet to be out.But once you have installed the Custom Configuration Designer you can see that you will get a project like the snapshot available for you to play around!
Once you have created the Custom Configuration ,you will get a default custom Section designer diagram which will be empty .Go to the properties and enter the values in Namespace and XmlSchemaNamespace as follows.
Once you are done naming your namespace as well as the xml schema namespace, you can go ahead and drag and drop the Config Section, Config Section Group, Configuration Collection as well as Configuration Element.Here is sample that I have created.Its really simple isn’t it?
And you can add custom classes to the existing predefined system types for your elements as well as the attributes as well as mention if it required and to make a certain attribute Key for a Config Collection.And then all you need to do is build it .
Recently i came across a situation wherein i had to host a WCF service as a Windows Service.Only after i installed the service using InstallUtil –i “assembly name”,did i realize my folly that i had a misconception regarding the term “Automatic”.What i am referring to the ServiceInstaller.StartType property.The main intent of this property is to start the Service automatically on start of Windows.
- this.serviceInstaller1.StartType =
So what do i do in run the service while installation?All you need to do add the event AfterInstall for the ServiceInstaller and then call the ServiceController from the eventhandler to start the service.
- public partial class ServiceInstaller : Installer
- public ServiceInstaller()
- ServiceProcessInstaller processInstaller = new ServiceProcessInstaller();
- ServiceInstaller serviceInstaller = new ServiceInstaller();
- //Specifies the type of account that should be used for the service.
- processInstaller.Account = ServiceAccount.LocalSystem;
- //Specifies the name of the service that is installed.
- serviceInstaller.DisplayName = "Josh Service";
- //Gives the description of the Installed service.
- serviceInstaller.Description = "this is a Win Service";
- //It tells which is the service that should be installed.
- serviceInstaller.ServiceName = "MyService";
- //It specifies the Start type of the service.
- serviceInstaller.StartType = ServiceStartMode.Automatic;
- this.AfterInstall += new InstallEventHandler(ServiceInstaller_AfterInstall);
- void ServiceInstaller_AfterInstall(object sender, InstallEventArgs e)
- ServiceController sc = new ServiceController("MyService");
“The service on local computer started and then stopped. Some Services stop automatically if they are not in use by another services or programs.”
You are all used to debugging and would have most likely than not used the “attach to process ” to debug your service implementation.But what do you do when you get Errors or have to debug the Windows Service installer itself?Bingo, we can always write “System.Diagnostics.Debugger.Launch();” in the OnStart() method and start debugging.Also you can write the errors to the EventLog or dump the Exception to a Log after putting in place a simple try catch!