Skip to content

Commit

Permalink
Merge pull request #1455 from FakeItEasy/release/4.9.0
Browse files Browse the repository at this point in the history
Release 4.9.0
  • Loading branch information
blairconrad committed Sep 27, 2018
2 parents 0a28896 + a426e87 commit 503c5d1
Show file tree
Hide file tree
Showing 32 changed files with 915 additions and 203 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ artifacts
src/VersionInfo.cs
src/FakeItEasy.nuspec
tools/packages.config.sha1
tools/FakeItEasy.Build/ToolPaths.cs
tools/*/ToolPaths.cs

*.*proj.user
*.lock.json
Expand Down
17 changes: 16 additions & 1 deletion FakeItEasy.sln
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,18 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FakeItEasy.Analyzer.VisualB
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{9D99B251-FB4F-49BF-8405-F6E0DE46EB32}"
ProjectSection(SolutionItems) = preProject
tools\deploy.ps1 = tools\deploy.ps1
tools\deploy.cmd = tools\deploy.cmd
tools\prepare_release.cmd = tools\prepare_release.cmd
EndProjectSection
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "FakeItEasy.Analyzer.Shared", "src\FakeItEasy.Analyzer.Shared\FakeItEasy.Analyzer.Shared.shproj", "{E3ED4908-BC8D-4D81-A31B-8CD0B67F41B4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FakeItEasy.Build", "tools\FakeItEasy.Build\FakeItEasy.Build.csproj", "{81779103-4CA9-4177-B78A-A435FC37DADC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FakeItEasy.PrepareRelease", "tools\FakeItEasy.PrepareRelease\FakeItEasy.PrepareRelease.csproj", "{0E2ED1CD-C7ED-4641-9482-C4BBBA58B623}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FakeItEasy.Deploy", "tools\FakeItEasy.Deploy\FakeItEasy.Deploy.csproj", "{5F4FC5FA-E2FA-456D-813F-6057B7CE7FF0}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
tests\FakeItEasy.Analyzer.Tests.Shared\FakeItEasy.Analyzer.Tests.Shared.projitems*{38f3191b-1ce0-4ee0-930f-794a2f2f4cdb}*SharedItemsImports = 4
Expand Down Expand Up @@ -186,6 +192,12 @@ Global
{C0B3EF5F-222E-4FD4-9B42-161AC6C56CB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0B3EF5F-222E-4FD4-9B42-161AC6C56CB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0B3EF5F-222E-4FD4-9B42-161AC6C56CB5}.Release|Any CPU.Build.0 = Release|Any CPU
{81779103-4CA9-4177-B78A-A435FC37DADC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81779103-4CA9-4177-B78A-A435FC37DADC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E2ED1CD-C7ED-4641-9482-C4BBBA58B623}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E2ED1CD-C7ED-4641-9482-C4BBBA58B623}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F4FC5FA-E2FA-456D-813F-6057B7CE7FF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F4FC5FA-E2FA-456D-813F-6057B7CE7FF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -209,6 +221,9 @@ Global
{EF850910-1B7F-4824-8034-0A935B8C9152} = {59466C4D-C407-4DD9-B77B-D99162B9FC7C}
{C0B3EF5F-222E-4FD4-9B42-161AC6C56CB5} = {59466C4D-C407-4DD9-B77B-D99162B9FC7C}
{E3ED4908-BC8D-4D81-A31B-8CD0B67F41B4} = {59466C4D-C407-4DD9-B77B-D99162B9FC7C}
{81779103-4CA9-4177-B78A-A435FC37DADC} = {9D99B251-FB4F-49BF-8405-F6E0DE46EB32}
{0E2ED1CD-C7ED-4641-9482-C4BBBA58B623} = {9D99B251-FB4F-49BF-8405-F6E0DE46EB32}
{5F4FC5FA-E2FA-456D-813F-6057B7CE7FF0} = {9D99B251-FB4F-49BF-8405-F6E0DE46EB32}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E70BBF50-5920-49F2-835D-4A2DBD73F0E1}
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ A .Net dynamic fake framework for creating all types of fake objects, mocks, stu
* [Documentation](http://fakeiteasy.readthedocs.io/en/stable/)
* [Chat](https://gitter.im/FakeItEasy/FakeItEasy)
* NuGet packages:
* [Official releases on NuGet.org](https://www.nuget.org/profiles/FakeItEasy "FakeItEasy's packages on NuGet.org"), targeting
.NETStandard 1.6, .NETFramework 4.5, and .NETFramework 4.0
* [Official releases on NuGet.org](https://www.nuget.org/profiles/FakeItEasy "FakeItEasy's packages on NuGet.org"), targeting:
* .NET Standard 2.0
* .NET Standard 1.6
* .NET Framework 4.5
* .NET Framework 4.0
* Unreleased packages built from latest source are on AppVeyor:<br>
https://ci.appveyor.com/nuget/FakeItEasy

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ artifacts:
- path: .\artifacts\*\*

deploy_script:
- ps: .\tools\deploy.ps1
- cmd: tools\deploy.cmd
5 changes: 0 additions & 5 deletions global.json

This file was deleted.

15 changes: 11 additions & 4 deletions how_to_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,24 @@ At the time of writing the build is only confirmed to work on Windows using the

## Prerequisites

1. Ensure you have .NET framework 4.6.1 or later installed.
The build requires that a few pieces of software be installed on the host computer. We're somewhat aggressive about adoptiong new language features and the like, so rather than specifying exactly which versions are required, we'll tend toward
"latest" or "at least" forms of guidance. If it seems you have an incompatible version of the software, prefer to upgrade rather than downgrade.

1. Ensure you have version 15.3 or later of either Visual Studio 2017 or MSBuild installed.
Ensure that the following are installed:

1. Ensure you have .NET Core SDK 2.0.2 or later installed
1. .NET 3.5, required by ILMerge

1. a recent version of Visual Studio 2017 (currently this means 15.7 or later) or the Build Tools for Visual Studio 2017

1. a recent version of the .NET Core 1.0 Runtime (currently this means 1.0.12 or later)

1. a recent version of the .NET Core 2.1 SDK (currently this means 2.1.3 or later)

## Building

Using a command prompt, navigate to your clone root folder and execute `build.cmd`.

This executes the default build targets to produce both the .NET Standard and the .NET 4.0 artifacts.
This executes the default build targets to produce both .NET Standard and .NET Framework artifacts.

After the build has completed, the build artifacts will be located in `artifacts`.

Expand Down
10 changes: 6 additions & 4 deletions src/FakeItEasy/Core/TypeCatalogue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static IEnumerable<Assembly> GetAllAssemblies(IEnumerable<string> extraA
// Find the paths of already loaded assemblies so we don't double scan them.
var loadedAssemblyFiles = new HashSet<string>(
loadedAssemblies
#if FEATURE_REFLECTION_GETASSEMBLIES
#if FEATURE_REFLECTIONONLYLOAD
// Exclude the ReflectionOnly assemblies because we may fully load them later.
.Where(a => !a.ReflectionOnly)
#endif
Expand All @@ -118,10 +118,12 @@ private static IEnumerable<Assembly> GetAssemblies(IEnumerable<string> files)
Assembly assembly;
try
{
#if FEATURE_REFLECTION_GETASSEMBLIES
#if FEATURE_REFLECTIONONLYLOAD
assembly = Assembly.ReflectionOnlyLoadFrom(file);
#else
#elif USE_RUNTIMELOADER
assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(file);
#else
assembly = Assembly.LoadFrom(file);
#endif
}
catch (Exception ex)
Expand All @@ -135,7 +137,7 @@ private static IEnumerable<Assembly> GetAssemblies(IEnumerable<string> files)
continue;
}

#if FEATURE_REFLECTION_GETASSEMBLIES
#if FEATURE_REFLECTIONONLYLOAD
// A reflection-only loaded assembly can't be scanned for types, so fully load it before returning it.
try
{
Expand Down
2 changes: 1 addition & 1 deletion src/FakeItEasy/Creation/DummyValueResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public DummyValueResolver(DynamicDummyFactory dummyFactory, IFakeObjectCreator f
new ResolveFromDummyFactoryStrategy(dummyFactory),
new ResolveByCreatingTaskStrategy(this),
new ResolveByCreatingLazyStrategy(this),
new ResolveByCreatingFakeStrategy(fakeObjectCreator, this),
new ResolveByActivatingValueTypeStrategy(),
new ResolveByCreatingFakeStrategy(fakeObjectCreator, this),
new ResolveByInstantiatingClassUsingDummyValuesAsConstructorArgumentsStrategy(this)
};
}
Expand Down
9 changes: 9 additions & 0 deletions src/FakeItEasy/Creation/StringDummyFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace FakeItEasy
{
internal class StringDummyFactory : DummyFactory<string>
{
public override Priority Priority => Priority.Internal;

protected override string Create() => string.Empty;
}
}
18 changes: 14 additions & 4 deletions src/FakeItEasy/FakeItEasy.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net40;net45;netstandard1.6</TargetFrameworks>
<TargetFrameworks>net40;net45;netstandard1.6;netstandard2.0</TargetFrameworks>
<AssemblyName>FakeItEasy</AssemblyName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<FileAlignment>512</FileAlignment>
Expand Down Expand Up @@ -37,10 +37,20 @@
<DebugType>pdbonly</DebugType>
</PropertyGroup>

<!-- .NET Standard 2.0 -->

<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>$(DefineConstants);FEATURE_REFLECTION_GETASSEMBLIES;FEATURE_EXCEPTION_DISPATCH_INFO;FEATURE_ARRAY_EMPTY;FEATURE_PARAMETERINFO_CUSTOMATTRIBUTES_PROPERTY</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Castle.Core" Version="$(CastleCoreVersion)" />
</ItemGroup>

<!-- .NET Standard 1.6 -->

<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.6'">
<DefineConstants>$(DefineConstants);FEATURE_NETCORE_REFLECTION;FEATURE_EXCEPTION_DISPATCH_INFO;FEATURE_ARRAY_EMPTY;FEATURE_PARAMETERINFO_CUSTOMATTRIBUTES_PROPERTY</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_NETCORE_REFLECTION;USE_RUNTIMELOADER;FEATURE_EXCEPTION_DISPATCH_INFO;FEATURE_ARRAY_EMPTY;FEATURE_PARAMETERINFO_CUSTOMATTRIBUTES_PROPERTY</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.6'">
Expand All @@ -53,7 +63,7 @@
<!-- .NET 4.5 -->

<PropertyGroup Condition="'$(TargetFramework)' == 'net45'">
<DefineConstants>$(DefineConstants);FEATURE_BINARY_SERIALIZATION;FEATURE_REFLECTION_GETASSEMBLIES;FEATURE_PARAMETERINFO_CUSTOMATTRIBUTES_PROPERTY</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_BINARY_SERIALIZATION;FEATURE_REFLECTION_GETASSEMBLIES;FEATURE_REFLECTIONONLYLOAD;FEATURE_PARAMETERINFO_CUSTOMATTRIBUTES_PROPERTY</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
Expand All @@ -68,7 +78,7 @@
<!-- .NET 4.0 -->

<PropertyGroup Condition="'$(TargetFramework)' == 'net40'">
<DefineConstants>$(DefineConstants);FEATURE_BINARY_SERIALIZATION;FEATURE_REFLECTION_GETASSEMBLIES;FEATURE_EVENT_ARGS_MUST_EXTEND_EVENTARGS</DefineConstants>
<DefineConstants>$(DefineConstants);FEATURE_BINARY_SERIALIZATION;FEATURE_REFLECTION_GETASSEMBLIES;FEATURE_REFLECTIONONLYLOAD;FEATURE_EVENT_ARGS_MUST_EXTEND_EVENTARGS</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
Expand Down
11 changes: 4 additions & 7 deletions tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="xunit.core" Version="2.3.0-beta2-build3683" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta2-build1317" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="xunit.core" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="XunitXml.TestLogger" Version="2.0.0" />
<PackageReference Include="FluentAssertions" Version="4.19.2" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta2-build3683" />
</ItemGroup>

</Project>
28 changes: 20 additions & 8 deletions tests/FakeItEasy.IntegrationTests/ExternalAssemblyGenerator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace FakeItEasy.IntegrationTests
namespace FakeItEasy.IntegrationTests
{
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -56,6 +56,15 @@ private static IEnumerable<string> GetFrameworkAssemblyLocations()
});
}

#if REQUIRES_NETSTANDARD_REFERENCE
private static string GetNetStandardAssemblyLocation()
{
var assembly = AppDomain.CurrentDomain.GetAssemblies()
.First(a => string.Equals(a.GetName().Name, "netstandard", StringComparison.OrdinalIgnoreCase));
return assembly.Location;
}
#endif

private string baseDirectory;

private void CreateBaseDirectory()
Expand Down Expand Up @@ -129,12 +138,15 @@ protected override string GetStringValue(Foo argumentValue)
";

var references = GetFrameworkAssemblyLocations()
.Concat(new[]
{
typeof(A).GetTypeInformation().Assembly.Location,
this.AssemblyDependencyPath
})
.Select(l => MetadataReference.CreateFromFile(l));
.Concat(new[]
{
typeof(A).GetTypeInformation().Assembly.Location,
#if REQUIRES_NETSTANDARD_REFERENCE
GetNetStandardAssemblyLocation(),
#endif
this.AssemblyDependencyPath
})
.Select(l => MetadataReference.CreateFromFile(l));

var compilation = CSharpCompilation.Create(
AssemblyName,
Expand All @@ -154,4 +166,4 @@ private void CopyAssembly()
File.Copy(this.AssemblyOriginalPath, this.AssemblyCopyPath);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp1.0;netcoreapp2.1</TargetFrameworks>
<AssemblyName>FakeItEasy.IntegrationTests</AssemblyName>
<SignAssembly>true</SignAssembly>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<DefineConstants>$(DefineConstants);FEATURE_NETCORE_REFLECTION;FEATURE_STRING_CONTAINS_COMPARISONTYPE;REQUIRES_NETSTANDARD_REFERENCE</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">
<DefineConstants>$(DefineConstants);FEATURE_NETCORE_REFLECTION</DefineConstants>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public static string StartsWith(this IArgumentConstraintManager<string> scope, s

public static string Contains(this IArgumentConstraintManager<string> scope, string value)
{
#if FEATURE_STRING_CONTAINS_COMPARISONTYPE
return scope.Matches(x => x.Contains(value, StringComparison.CurrentCulture), $@"Contains ""{value}""");
#else
return scope.Matches(x => x.Contains(value), $@"Contains ""{value}""");
#endif
}
}
}
6 changes: 2 additions & 4 deletions tests/FakeItEasy.Specs/CreationSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public interface IInterfaceWithSimilarMethods
// unsuccessful constructors may be called more than once, so serialize fake
// creation for this test.
"And nobody else is trying to fake the class right now"
.x(() => ClassWhosePreferredConstructorsThrow.FakingLock.Wait(TimeSpan.FromSeconds(30)))
.Teardown(() => ClassWhosePreferredConstructorsThrow.FakingLock.Set());
.x(() => Monitor.TryEnter(typeof(ClassWhosePreferredConstructorsThrow), TimeSpan.FromSeconds(30)).Should().BeTrue("we must enter the monitor"))
.Teardown(() => Monitor.Exit(typeof(ClassWhosePreferredConstructorsThrow)));

"When I create a fake of the class"
.x(() => fake1 = this.CreateFake<ClassWhosePreferredConstructorsThrow>());
Expand All @@ -190,8 +190,6 @@ public interface IInterfaceWithSimilarMethods

public class ClassWhosePreferredConstructorsThrow
{
public static ManualResetEventSlim FakingLock { get; } = new ManualResetEventSlim(true);

public static int NumberOfTimesParameterlessConstructorWasCalled => numberOfTimesParameterlessConstructorWasCalled;

public static int NumberOfTimesTwoParameterConstructorWasCalled => numberOfTimesTwoParameterConstructorWasCalled;
Expand Down
27 changes: 23 additions & 4 deletions tests/FakeItEasy.Specs/DummyCreationSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ public abstract class DummyCreationSpecsBase
.x(() => dummy.Should().Be(default(int?)));
}

[Scenario]
public void StringCreation(
string dummy1,
string dummy2)
{
"When a dummy string is requested"
.x(() => dummy1 = this.CreateDummy<string>());

"And another dummy string is requested"
.x(() => dummy2 = this.CreateDummy<string>());

"Then it returns an empty string the first time"
.x(() => dummy1.Should().Be(string.Empty));

"Then it returns an empty string the second time"
.x(() => dummy2.Should().Be(string.Empty));

"And the two strings are the same reference"
.x(() => dummy1.Should().BeSameAs(dummy2));
}

[Scenario]
public void TypeWithDummyFactoryCreation(
Foo dummy)
Expand Down Expand Up @@ -115,8 +136,8 @@ public abstract class DummyCreationSpecsBase
// unsuccessful constructors may be called more than once, so serialize dummy
// creation for this test.
"And nobody else is trying to create a dummy of the class right now"
.x(() => ClassWhoseLongerConstructorThrows.DummyingLock.Wait(TimeSpan.FromSeconds(30)))
.Teardown(() => ClassWhoseLongerConstructorThrows.DummyingLock.Set());
.x(() => Monitor.TryEnter(typeof(ClassWhoseLongerConstructorThrows), TimeSpan.FromSeconds(30)).Should().BeTrue("we must enter the monitor"))
.Teardown(() => Monitor.Exit(typeof(ClassWhoseLongerConstructorThrows)));

"When a dummy of that type is requested"
.x(() => dummy1 = this.CreateDummy<ClassWhoseLongerConstructorThrows>());
Expand Down Expand Up @@ -435,8 +456,6 @@ protected override Foo Create()

public sealed class ClassWhoseLongerConstructorThrows
{
public static ManualResetEventSlim DummyingLock { get; } = new ManualResetEventSlim(true);

private static int numberOfTimesLongerConstructorWasCalled;

public string CalledConstructor { get; }
Expand Down
8 changes: 2 additions & 6 deletions tests/FakeItEasy.Specs/FakeItEasy.Specs.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>net461;netcoreapp1.0;netcoreapp2.1</TargetFrameworks>
<AssemblyName>FakeItEasy.Specs</AssemblyName>
<CodeAnalysisRuleset>FakeItEasy.Specs.ruleset</CodeAnalysisRuleset>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">
<DefineConstants>$(DefineConstants);FEATURE_NETCORE_REFLECTION</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 503c5d1

Please sign in to comment.