Skip to content

Commit b6290cf

Browse files
committed
Add known type mapping support
1 parent 6c26316 commit b6290cf

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Rewrite/src/Rewrite.Core/Config/RecipeArgument.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@ public override required string Type
2323
init
2424
{
2525
_typeName = value;
26-
_type = System.Type.GetType(value) ?? throw new TypeLoadException($"Type {value} cannot be loaded");
26+
var type = value switch
27+
{
28+
"string" => typeof(string),
29+
"int" => typeof(int),
30+
"long" => typeof(long),
31+
"bool" => typeof(bool),
32+
"float" => typeof(float),
33+
"double" => typeof(double),
34+
_ => System.Type.GetType(value)
35+
} ?? throw new TypeLoadException($"Type {value} cannot be loaded");
36+
_type = type;
2737
}
2838
}
2939

Rewrite/tests/Rewrite.MSBuild.Tests/RpcTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Rewrite.MSBuild.Tests;
1616
public class RpcTests
1717
{
1818
[Test]
19+
[Explicit]
1920
public void NewValue()
2021
{
2122
AnsiConsole.Reset();
@@ -45,6 +46,7 @@ public class MyClass
4546
}
4647

4748
[Test]
49+
[Explicit]
4850
public void UpdatedValue()
4951
{
5052

0 commit comments

Comments
 (0)