Skip to content

Commit

Permalink
Merge pull request #439 from slang25/cross-plat-bug
Browse files Browse the repository at this point in the history
Make diff tools configuration lazy
  • Loading branch information
josephwoodward committed Jul 20, 2017
2 parents cda1511 + f3eabfc commit c487414
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
6 changes: 2 additions & 4 deletions src/Shouldly/Configuration/VisualStudioDiffTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,10 @@ static string VisualStudioArgs(string received, string approved, bool approvedEx
// https://github.com/approvals/ApprovalTests.Net/blob/master/ApprovalTests/Reporters/VisualStudioReporter.cs
private static string GetPath()
{
var processAndParent = ParentProcessUtils.CurrentProcessWithAncestors().ToArray();

Process process = null;

Process process;
try
{
var processAndParent = ParentProcessUtils.CurrentProcessWithAncestors();
process = processAndParent.FirstOrDefault(x => x.MainModule.FileName.EndsWith("devenv.exe"));
}
catch (Exception)
Expand Down
10 changes: 0 additions & 10 deletions src/Shouldly/Shouldly.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Shouldly - Assertion framework for .NET. The way asserting *Should* be</Description>
<TargetFrameworks>net451;net40;netstandard1.3</TargetFrameworks>
Expand All @@ -10,17 +9,13 @@
<PackageProjectUrl>http://shouldly.github.com</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/shouldly/shouldly/blob/master/LICENSE.txt</PackageLicenseUrl>
<NetStandardImplicitPackageVersion>1.6.1</NetStandardImplicitPackageVersion>

<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<IncludeSymbols>True</IncludeSymbols>
<IncludeSource>True</IncludeSource>

<ComVisible>false</ComVisible>

<AssemblyOriginatorKeyFile>sn.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
Expand All @@ -31,22 +26,17 @@
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
<DefineConstants>$(DefineConstants);ShouldMatchApproved;StackTrace;Serializable;CallerMemberNamePolyfill</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net451' ">
<DefineConstants>$(DefineConstants);ShouldMatchApproved;StackTrace;Serializable</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<DefineConstants>$(DefineConstants);NewReflection;ExpressionTrees</DefineConstants>
</PropertyGroup>

</Project>
8 changes: 7 additions & 1 deletion src/Shouldly/ShouldlyConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ static ShouldlyConfiguration()

public static List<string> CompareAsObjectTypes { get; private set; }
#if ShouldMatchApproved
public static DiffToolConfiguration DiffTools { get; private set; } = new DiffToolConfiguration();
private static Lazy<DiffToolConfiguration> _lazyDiffTools = new Lazy<DiffToolConfiguration>(() => new DiffToolConfiguration());
public static DiffToolConfiguration DiffTools {
get => _lazyDiffTools.Value;
private set {
_lazyDiffTools = new Lazy<DiffToolConfiguration>(() => value);
}
}

public static ShouldMatchConfigurationBuilder ShouldMatchApprovedDefaults { get; private set; } =
new ShouldMatchConfigurationBuilder(new ShouldMatchConfiguration
Expand Down

0 comments on commit c487414

Please sign in to comment.