Skip to content

Instantly share code, notes, and snippets.


Troy Dai troydai

View GitHub Profile
troydai /
Last active Jan 12, 2018
Purpose: Azure CLI alias

What is az alias

The az alias is an extension point allows user to define their own command alias based on existing commands. The alias will enable scenarios which improve the usability of azure cli.

The definition of the aliases could be a configuration file in a uesr friendly format, like yaml or ini

An inspiration of the alias system is git alias


troydai /
Created Sep 6, 2017
Register module correlation ID
def load_params(_):
import # pylint: disable=redefined-outer-name, unused-variable
from azure.cli.core.telemetry import set_module_correlation_data
from datetime import datetime
set_module_correlation_data('module correlation {}'.format('%Y %m %d %H:%M:%S')))
View web.config
<httpErrors errorMode="Detailed" />
<!--<rule name="ForceSSL" stopProcessing="true">-->
<!-- <match url="^(.*)" />-->
<!-- <conditions>-->
<!-- <add input="{HTTPS}" pattern="^off$" ignoreCase="true" />-->
<!-- </conditions>-->
View gist:67d899b5b7b78b72e38c9b6ad90f5c74
1. Improve test coverage
2. Improve turnaround
1. Prompt unit tests and their code coverage
2. Measure testing quality frequently and reguarly.
3. Monitor the changes of the product percisely and reguarly.
troydai / pmserver.log
Created Apr 2, 2016
pmserver log during references removal
View pmserver.log
info: Microsoft.DotNet.ProjectModel.Server.ProcessingQueue[0]
OnReceive ((cc7e9be66bdb40e6a62a041777d75a79, FilesChanged, 1) -> null)
info: Microsoft.DotNet.ProjectModel.Server.ProjectManager[0]
Begin draining inbox.
info: Microsoft.DotNet.ProjectModel.Server.ProjectManager[0]
Received FilesChanged
info: Microsoft.DotNet.ProjectModel.Server.ProjectManager[0]
Finish draining inbox.
info: Microsoft.DotNet.ProjectModel.Server.ProcessingQueue[0]
OnSend ((cc7e9be66bdb40e6a62a041777d75a79, DependencyDiagnostics, 1) -> {
troydai / DTH.log
Created Mar 28, 2016
A sample xproj DTH log
View DTH.log
Project Microsoft.DotNet.InternalAbstractions (.NETStandard,Version=v1.3) was previously compiled. Skipping compilation.
Project Microsoft.Extensions.DependencyModel (.NETStandard,Version=v1.5) was previously compiled. Skipping compilation.
Project Microsoft.DotNet.ProjectModel (.NETStandard,Version=v1.5) was previously compiled. Skipping compilation.
Project Microsoft.DotNet.Cli.Utils (.NETStandard,Version=v1.5) was previously compiled. Skipping compilation.
Project Microsoft.DotNet.Files (.NETStandard,Version=v1.5) was previously compiled. Skipping compilation.
Project Microsoft.DotNet.Compiler.Common (.NETStandard,Version=v1.5) was previously compiled. Skipping compilation.
Project Microsoft.Extensions.Testing.Abstractions (.NETStandard,Version=v1.5) was previously compiled. Skipping compilation.
Project dotnet (.NETStandardApp,Version=v1.5) was previously compiled. Skipping compilation.
Project Microsoft.DotNet.TestFramework (.NETStandard,Version=v1.5) was previously compiled. Skipping compilation.
troydai /
Created Mar 18, 2016
xproj -> csproj proposed scenario.

xproj -> csproj

Scenario: Add csproj refernece to xproj through UI

  1. There are xproj project A, and csproj project B. The dependency relationship is not established now.
  2. User add project B as a reference to A through Visual Studio UI.
  3. WTE add project B reference to project A's xproj file.
  4. WTE walk through the csproj graph and build a dg file.
  5. dotnet restore restores projects. Relies on the dg file generated in previous steps it manages to walk through all csproj files. It generated project.lock.json for project A. The lock file has project references to project B as well as all csproj it references. The lock file only provide the path to the csproj files.
  6. WTE walk down the entire msbuild project graph. For each csproj file it reachs it generates a fragment lock file.
troydai / DthWorkspace.cs
Last active Oct 29, 2015
DTH Prototype
View DthWorkspace.cs
namespace Prototype
public interface IDthWorkspace
int InitializeProject(string projectPath, string configuration);
void ChangeConfiguration(string configuration);
IDictionary<string, int> GetProjectContexts();
troydai / Sample.json
Created Oct 9, 2015
The example of prototype 2744
View Sample.json
"System.Reflection.Primitives": {
"Name": "System.Reflection.Primitives",
"DisplayName": "System.Reflection.Primitives",
"Version": "4.0.0",
"Path": "C:\\Users\\trdai\\.dnx\\packages\\System.Reflection.Primitives\\4.0.0",
"Type": "Package",
"Resolved": true,
"Dependencies": [
"Name": "System.Runtime",
View A time logger
using System;
using System.IO;
namespace Microsoft.Dnx.Testing
public class TimeLogger
private readonly string _file;
private TimeLogger()
You can’t perform that action at this time.