-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generator improvements: support templates for specific targets (i.e. …
…net40, net45)
- Loading branch information
Showing
14 changed files
with
503 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace FluentJsonNet.Tests | ||
{ | ||
/// <summary> | ||
/// The is a tag class that provides information about this assembly. | ||
/// It can be used to locate the assembly: i.e. typeof(ProjectMetadata) | ||
/// </summary> | ||
public class ProjectMetadata | ||
{ | ||
public readonly string Name = "FluentJsonNet.Tests"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
ProjectGenerator/Templates/net40/%TestProjectName%.net40/%TestProjectName%.net40.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>%TestProjectGuid%</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>%TestProjectName%.net40</RootNamespace> | ||
<AssemblyName>%TestProjectName%.net40</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Assert.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\%TestProjectName%\%TestProjectName%.csproj"> | ||
<Project>%TestProjectRefGuid%</Project> | ||
<Name>%TestProjectName%</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
48 changes: 48 additions & 0 deletions
48
ProjectGenerator/Templates/net40/%TestProjectName%.net40/Assert.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace %TestProjectName%.net40 | ||
{ | ||
internal class MyAssert : Asserter | ||
{ | ||
public override void AreEqual<T>(T expected, T value) | ||
{ | ||
var prev = Console.ForegroundColor; | ||
var eql = EqualityComparer<T>.Default.Equals(expected, value); | ||
Console.ForegroundColor = eql ? ConsoleColor.Green : ConsoleColor.Red; | ||
Console.Write(eql ? " OK " : " FAIL "); | ||
Console.ForegroundColor = prev; | ||
Console.WriteLine($"AreEqual({ToLiteral(expected)}, {ToLiteral(value)})"); | ||
} | ||
|
||
private static string ToLiteral<T>(T value) | ||
{ | ||
if (value == null) | ||
return "null"; | ||
|
||
if (value is string) | ||
{ | ||
var val = Regex.Replace( | ||
value.ToString(), | ||
@"[\r\n\t\0]", | ||
m => new[] { "\\r", "\\n", "\\t", "\\0" }["\r\n\t\0".IndexOf(m.Value)]); | ||
|
||
return $"\"{val}\""; | ||
} | ||
|
||
return value.ToString(); | ||
} | ||
|
||
public override void IsInstanceOfType(object value, Type expectedType, string message) | ||
{ | ||
var prev = Console.ForegroundColor; | ||
var ok = value != null && expectedType.IsAssignableFrom(value.GetType()); | ||
Console.ForegroundColor = ok ? ConsoleColor.Green : ConsoleColor.Red; | ||
Console.Write(ok ? " OK " : " FAIL "); | ||
Console.ForegroundColor = prev; | ||
Console.WriteLine($"IsInstanceOfType({ToLiteral(value)}, typeof({expectedType.ToString()}), {ToLiteral(message)})"); | ||
} | ||
} | ||
} |
Oops, something went wrong.