Skip to content

Commit

Permalink
#2 Add preprocessor directives to Sandbox
Browse files Browse the repository at this point in the history
This enables us to verify support for different target frameworks by running the sandbox.
  • Loading branch information
sguldmund committed Jan 12, 2024
1 parent 79d4905 commit 7cba5e4
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 21 deletions.
91 changes: 71 additions & 20 deletions src/Sandbox/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,81 @@ public class Program
{
public static void Main(string[] args)
{
var dateTimeShim = Shim.Replace(() => T.I).With(() => "L");
var dateTimeShim1 = Shim.Replace(() => T.Get()).With(() => "Word");
var inst = new Inst();
var f = new Func<Inst, string>(i => "Word");
var dateTimeShim2 = Shim.Replace(() => inst.S).With(f);
var dateTimeShim3 = Shim.Replace(() => inst.Get()).With(f);
var dateTimeShim4 = Shim.Replace(() => Is.A<Inst>().S).With(f);
var dateTimeShim5 = Shim.Replace(() => Is.A<Inst>().Get()).With(f);
var dateTimeShim6 = Shim.Replace(() => Is.A<Inst>().Get()).With(delegate(Inst @this) { return "Word"; });

#if NET48
Console.WriteLine("4.8");
var dateTimeShim = Shim.Replace(() => DateTime.Now).With(() => new DateTime(2004, 1, 1));
PoseContext.Isolate(
() =>
{
// Console.Write(T.I);
// Console.WriteLine(T.Get());
try
{
Console.WriteLine(inst.S);
}
catch (Exception e) { }
finally { }
Console.WriteLine(DateTime.Now);
}, dateTimeShim);
#elif NETCOREAPP2_0
Console.WriteLine("2.0");
var dateTimeShim = Shim.Replace(() => DateTime.Now).With(() => new DateTime(2004, 1, 1));
PoseContext.Isolate(
() =>
{
Console.WriteLine(DateTime.Now);
}, dateTimeShim);
#elif NET6_0
Console.WriteLine("6.0");
var dateTimeShim = Shim.Replace(() => DateTime.Now).With(() => new DateTime(2004, 1, 1));
PoseContext.Isolate(
() =>
{
Console.WriteLine(DateTime.Now);
}, dateTimeShim);
#elif NET7_0
Console.WriteLine("7.0");

var dateTimeShim = Shim.Replace(() => DateTime.Now).With(() => new DateTime(2004, 1, 1));
PoseContext.Isolate(
() =>
{
Console.WriteLine(DateTime.Now);
}, dateTimeShim);
#elif NETCOREAPP3_0
Console.WriteLine("3.0");
var dateTimeShim = Shim.Replace(() => DateTime.Now).With(() => new DateTime(2004, 1, 1));
PoseContext.Isolate(
() =>
{
Console.WriteLine(DateTime.Now);
}, dateTimeShim);
#else
Console.WriteLine("Other");
var dateTimeShim = Shim.Replace(() => DateTime.Now).With(() => new DateTime(2004, 1, 1));
PoseContext.Isolate(
() =>
{
Console.WriteLine(DateTime.Now);
}, dateTimeShim);
#endif

// Console.WriteLine(T.I);
}, dateTimeShim, dateTimeShim4);
// var dateTimeShim = Shim.Replace(() => T.I).With(() => "L");
// var dateTimeShim1 = Shim.Replace(() => T.Get()).With(() => "Word");
// var inst = new Inst();
// var f = new Func<Inst, string>(i => "Word");
// var dateTimeShim2 = Shim.Replace(() => inst.S).With(f);
// var dateTimeShim3 = Shim.Replace(() => inst.Get()).With(f);
// var dateTimeShim4 = Shim.Replace(() => Is.A<Inst>().S).With(f);
// var dateTimeShim5 = Shim.Replace(() => Is.A<Inst>().Get()).With(f);
// var dateTimeShim6 = Shim.Replace(() => Is.A<Inst>().Get()).With(delegate(Inst @this) { return "Word"; });
//
// PoseContext.Isolate(
// () =>
// {
// // Console.Write(T.I);
// // Console.WriteLine(T.Get());
// try
// {
// Console.WriteLine(inst.S);
// }
// catch (Exception e) { }
// finally { }
//
// // Console.WriteLine(T.I);
// }, dateTimeShim, dateTimeShim4);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sandbox/Sandbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFrameworks>netcoreapp2.0;netcoreapp3.0;net6.0;net7.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 7cba5e4

Please sign in to comment.