CSharpCompilerSettingsForUnity
CSharpCompilerSettingsForUnity copied to clipboard
Support C# 9 Source Generators
Thanks for building this great project. I tried this project and it works great with C# 9 syntax. However, I cannot make it work with C# 9 Source Generators. May I know if this support? I am using Unity 2020.3.
I have the same question.
@mob-sakai any comments here?
@shwuhk @shtse8 @hellozyemlya Sorry for my late reply. I'm working on this feature. It will be released soon!
@shwuhk @shtse8 @hellozyemlya
v1.5.0
supports source generator packages 👍
UnitGenerator example:
#if CUSTOM_COMPILE // This directive is required for Unity 2021.1 or later.
using NUnit.Framework;
namespace SourceGenerator
{
public class Unit
{
[Test]
public void UnitToString()
{
var userId = new UserId(1234);
Assert.AreEqual("UserId(1234)", userId.ToString());
}
[Test]
public void AsPrimitive()
{
var userId = new UserId(1234);
Assert.AreEqual(1234, userId.AsPrimitive());
}
}
[UnitGenerator.UnitOf(typeof(int))]
public readonly partial struct UserId { }
}
#endif
Feature looks great testing it now. Do I understand correctly that source genrator has to be in NuGet? Is it possible to add custom generators by adding dll to the project?