Skip to content

Commit

Permalink
yet another try
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyerst committed Mar 5, 2022
1 parent dbe9a27 commit f83d6bd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
9 changes: 3 additions & 6 deletions FastGenericNew.Tests/DemoTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ private DemoClassPrivateCtor() { }

private DemoClassPrivateCtor(int val) => value = val;

// Keep references to avoid Roslyn remove them.
public static void A()
{
Console.Write(new DemoClassPrivateCtor());
Console.Write(new DemoClassPrivateCtor(1));
}
public static DemoClassPrivateCtor Create() => new();

public static DemoClassPrivateCtor Create(int val) => new(val);
}

public record class DemoClass
Expand Down
6 changes: 4 additions & 2 deletions FastGenericNew.Tests/FastNewPrimaryTypesTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ public void CreateInstanceClassParameter()
public void CreateInstanceClassPrivateCtor()
{
var actual = FastNew.CreateInstance<DemoClassPrivateCtor>();
Assert.AreEqual(DemoClassPrivateCtor.DefaultValue, actual.value);
var expected = DemoClassPrivateCtor.Create();
Assert.AreEqual(expected, actual);
}

[Test()]
public void CreateInstanceClassPrivateParameterCtor()
{
const int val = 99999;
var actual = FastNew.CreateInstance<DemoClassPrivateCtor, int>(val);
Assert.AreEqual(val, actual.value);
var expected = DemoClassPrivateCtor.Create(val);
Assert.AreEqual(expected, actual);
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Environment:
Version = 3.0.0.0
Runtime = .NET Framework 4.8.4470.0
System = Microsoft Windows 10.0.22000
Runtime = .NET 7.0.0-preview.1.22076.8
System = Microsoft Windows 10.0.22000
SystemArch = X64
ProcessArch = X64
ProcessorCount = 24
Expand Down

0 comments on commit f83d6bd

Please # to comment.