Skip to content

Commit

Permalink
Merge pull request #446 from slang25/ToolingMigration
Browse files Browse the repository at this point in the history
Kill net35 with fire
  • Loading branch information
josephwoodward committed Jul 18, 2017
2 parents ca449ae + fc1e80e commit cda1511
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 81 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if ExpressionTrees
using System;
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
Expand Down Expand Up @@ -289,5 +288,4 @@ private void Out(string s)
builder.Append(s);
}
}
}
#endif
}
24 changes: 0 additions & 24 deletions src/Shouldly/DifferenceHighlighting/DifferenceIndexConsolidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,4 @@ private int CenterDiffIndices(List<int> diffIndices)
return result;
}
}

#if ZipPolyfill
static class ZipPolyfill
{
public static IEnumerable<TResult> Zip<TFirst, TSecond, TResult>(this IEnumerable<TFirst> first, IEnumerable<TSecond> second, Func<TFirst, TSecond, TResult> resultSelector)
{
if (first == null) throw new ArgumentNullException(nameof(first));
if (second == null) throw new ArgumentNullException(nameof(second));
if (resultSelector == null) throw new ArgumentNullException(nameof(resultSelector));
return ZipIterator(first, second, resultSelector);
}

private static IEnumerable<TResult> ZipIterator<TFirst, TSecond, TResult>
(IEnumerable<TFirst> first,
IEnumerable<TSecond> second,
Func<TFirst, TSecond, TResult> resultSelector)
{
using (IEnumerator<TFirst> e1 = first.GetEnumerator())
using (IEnumerator<TSecond> e2 = second.GetEnumerator())
while (e1.MoveNext() && e2.MoveNext())
yield return resultSelector(e1.Current, e2.Current);
}
}
#endif
}
2 changes: 0 additions & 2 deletions src/Shouldly/Internals/StringHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,10 @@ internal static string ToStringAwesomely(this object value)
return info.GetValue(constant.Value).ToStringAwesomely();
}

#if ExpressionTrees
if (value is BinaryExpression)
{
return ExpressionToString.ExpressionStringBuilder.ToString(value.As<BinaryExpression>());
}
#endif

if (type.IsGenericType() && type.GetGenericTypeDefinition() == typeof(KeyValuePair<,>)){
var key = type.GetProperty("Key").GetValue(value, null);
Expand Down
6 changes: 2 additions & 4 deletions src/Shouldly/Internals/TaskExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if Async
using System;
using System;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -53,5 +52,4 @@ public static Task TimeoutAfter(this Task task, TimeSpan timeout)
return tcs.Task;
}
}
}
#endif
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if Dynamic
using System;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -38,5 +37,4 @@ public override string GenerateErrorMessage(IShouldlyAssertionContext context)
}
}
}
}
#endif
}
4 changes: 0 additions & 4 deletions src/Shouldly/MessageGenerators/ShouldAllBeMessageGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ public override string GenerateErrorMessage(IShouldlyAssertionContext context)
{
var codePart = context.CodePart;
var expectedValue = context.Expected.ToStringAwesomely();
#if ExpressionTrees
var expression = ExpressionToString.ExpressionStringBuilder.ToString(context.Filter);
#else
var expression = context.Filter;
#endif
return $@"{codePart}
should satisfy the condition
{expression}
Expand Down
6 changes: 2 additions & 4 deletions src/Shouldly/ShouldStaticClasses/DynamicShould.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if Dynamic
using System;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
Expand Down Expand Up @@ -45,5 +44,4 @@ public static void HaveProperty(dynamic dynamicTestObject, string propertyName,
}
}
}
}
#endif
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if Async
using System.Threading;
using System.Threading;
using System;
using System.Reflection;
using System.Threading.Tasks;
Expand Down Expand Up @@ -143,5 +142,4 @@ private static void PreserveStackTrace(Exception exception)
preserveStackTrace?.Invoke(exception, null);
}
}
}
#endif
}
6 changes: 2 additions & 4 deletions src/Shouldly/ShouldStaticClasses/ShouldThrowTask.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if Async
using System;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -374,5 +373,4 @@ private static Exception HandleAggregateException(AggregateException e, [Instant
throw new ShouldAssertException(new ExpectedActualShouldlyMessage(exceptionType, innerException.GetType(), customMessage).ToString());
}
}
}
#endif
}
6 changes: 2 additions & 4 deletions src/Shouldly/ShouldStaticClasses/ShouldThrowTaskAsync.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if Async
using System;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using JetBrains.Annotations;
Expand Down Expand Up @@ -134,5 +133,4 @@ public static Task<Exception> ThrowAsync(Func<Task> actual, [InstantHandle] Func
#endif
}
}
}
#endif
}
15 changes: 5 additions & 10 deletions src/Shouldly/Shouldly.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>Shouldly - Assertion framework for .NET. The way asserting *Should* be</Description>
<TargetFrameworks>net451;net40;net35;netstandard1.3</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.3</TargetFrameworks>
<TargetFrameworks>net451;net40;netstandard1.3</TargetFrameworks>
<AssemblyName>Shouldly</AssemblyName>
<PackageId>Shouldly</PackageId>
<PackageTags>test;unit;testing;TDD;AAA;should;testunit;rspec;assert;assertion;framework</PackageTags>
Expand Down Expand Up @@ -38,20 +37,16 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

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

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

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

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

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if Async
using System;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using JetBrains.Annotations;
Expand Down Expand Up @@ -66,5 +65,4 @@ public static Task<Exception> ShouldThrowAsync(this Func<Task> actual, [InstantH
return Should.ThrowAsync(actual, customMessage, exceptionType);
}
}
}
#endif
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if Async
using System;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using JetBrains.Annotations;
Expand Down Expand Up @@ -234,5 +233,4 @@ public static T ShouldNotThrow<T>(this Func<Task<T>> action, TimeSpan timeoutAft
return Should.NotThrowInternal(action, timeoutAfter, customMessage);
}
}
}
#endif
}
6 changes: 0 additions & 6 deletions src/Shouldly/ShouldlyMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ public ShouldContainWithCountShouldlyMessage(object expected, object actual, int
}
}

#if Async
internal class TaskShouldlyThrowMessage : ShouldlyMessage
{
public TaskShouldlyThrowMessage(object expected, string exceptionMessage, Func<string> customMessage, [CallerMemberName] string shouldlyMethod = null)
Expand Down Expand Up @@ -223,7 +222,6 @@ public AsyncShouldlyThrowShouldlyMessage(Type exception, [InstantHandle] Func<st
if (customMessage != null) ShouldlyAssertionContext.CustomMessage = customMessage();
}
}
#endif
#endif

internal abstract class ShouldlyMessage
Expand All @@ -235,12 +233,8 @@ internal abstract class ShouldlyMessage
new ShouldBeNullOrEmptyMessageGenerator(),
new ShouldBeEmptyMessageGenerator(),
new ShouldAllBeMessageGenerator(),
#if Dynamic
new DynamicShouldMessageGenerator(),
#endif
#if Async
new ShouldCompleteInMessageGenerator(),
#endif
new ShouldBeNullOrWhiteSpaceMessageGenerator(),
new DictionaryShouldContainKeyAndValueMessageGenerator(),
new DictionaryShouldOrNotContainKeyMessageGenerator(),
Expand Down

0 comments on commit cda1511

Please sign in to comment.