Skip to content

Instantly share code, notes, and snippets.

Avatar

Mohamed Hassan moh-hassan

View GitHub Profile
View command.yml
version: 2.6.0-dev.{build}
image:
# Visual Studio 2017
- Ubuntu
init:
- sudo apt-get install -y nuget mono-complete
- mono -V
# mono --gc=sgen ~/src/code/Tools/MSBuild/Developer/bin/xunit.console.exe
View test.yml
#version is nly changed by RELEASE TAG
version: 2.5.2-dev.{build}
image:
#- Visual Studio 2017
- Ubuntu
#shallow_clone: true
pull_requests:
@moh-hassan
moh-hassan / defineconst.csproj
Created Apr 8, 2019
define constant in msbuild project: NETFRAMEWORK, NETSTANDARD and NETCORE
View defineconst.csproj
<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
<DefineConstants>$(DefineConstants);NETFRAMEWORK</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('netcoreapp'))">
<DefineConstants>$(DefineConstants);NETCORE</DefineConstants>
</PropertyGroup>
View BaseTest.cs
/*
In Xunit, NUnit or Test projects, inherit this class to avoid null exception
due to null assembly attributes when using CommandLineParser library
*/
public class BaseTest
{
public BaseTest()
{
//in Full Framework NET4x only, because no appdomain in netcore
View Generating schema manually with external reference using NJsonSchema
The generated schema with external reference manually using NJsonSchema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"title": "personal",
"additionalProperties": false,
"properties": {
"name": {
"type": "string"
View gist:c294ff07178e9457d78ac06f337357d1
//Lab demo using smo
//Server sql server 2012
//client has smo installed for sql 2016
using System;
using System.Data;
using ConsoleApplication1;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;
View gist:b5b48f6b9d1702c576864fa34d3dfbc8
The following Method Catch details of SqlException which can be logged or displayed to user
public StringBuilder SqlExceptionMessage(SqlException ex)
{
StringBuilder sqlErrorMessages = new StringBuilder("Sql Exception:\n");
foreach (SqlError error in ex.Errors)
{
sqlErrorMessages.AppendFormat("Mesage: {0}\n", error.Message)
.AppendFormat("Severity level: {0}\n", error.Class)
View gist:4398f7ebdeffe8864547573b6e0c1e84
using System;
using System.Management;
namespace ConsoleDemo
{
class Printer
{
public enum TechnologyType
{
Other = 1,
You can’t perform that action at this time.