Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support C# 9 Source Generators #14

Open
shwuhk opened this issue Apr 6, 2021 · 5 comments
Open

Support C# 9 Source Generators #14

shwuhk opened this issue Apr 6, 2021 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@shwuhk
Copy link

shwuhk commented Apr 6, 2021

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.

@shwuhk shwuhk added the question Further information is requested label Apr 6, 2021
@shtse8
Copy link

shtse8 commented Apr 11, 2021

I have the same question.

@hellozyemlya
Copy link

@mob-sakai any comments here?

@mob-sakai
Copy link
Owner

@shwuhk @shtse8 @hellozyemlya
Sorry for my late reply.
I'm working on this feature.
It will be released soon!

@mob-sakai mob-sakai added enhancement New feature or request and removed question Further information is requested labels Dec 14, 2021
@mob-sakai mob-sakai changed the title Does it support C# 9 Source Generators? Support C# 9 Source Generators Dec 14, 2021
@mob-sakai
Copy link
Owner

@shwuhk @shtse8 @hellozyemlya
v1.5.0 supports source generator packages 👍

UnitGenerator example:

image

#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

@slimshader
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants