Testura/Testura.Code

Adding more Modifiers

Closed this issue · 6 comments

Hi,

We are using Testura to generate the classes to automate some parts of our code generation.
We are able to create the class with almost 90% correctness.
The main issue that we are facing right now is missing Modifiers like Async, Override and ReadOnly.
At present, Testura provides only Public, Private, Statuc, Abstract and Virtual.
Can we get the other 3 added as well?
I can initiate a PR and add it in if you are busy.

Thanks,

Hey!

That shouldnt be a problem. I can add it for you later today.

Thank you Mille!
Since I have you here, I just have one more question.
Is it possible to have a object initialization statement as well for a Field? Can this be added?
Eg: we have a field:
private readonly ILogger _logger = LoggerService.Logger();

Is it possible to have a field be declared this way?

Thanks,

I can look into it when I fix the other thing. It shouldn't be that hard.

I have now uploaded a new 0.10.0 release to nuget. It contains the new modifers and a way to generate your field.

You have an example in Testura.Code/src/Testura.Code.Tests/Generators/Class/FieldGeneratorTests.cs (Create_WhenCreatingFieldWithInitializer_ShouldGenerateCorrectCode)

or here:

FieldGenerator.Create(new Field("_logger", CustomType.Create("ILogger"), initializeWith: ReferenceGenerator.Create(new VariableReference("LoggerService", new MethodReference( "Logger")))))

Let me know if these seems okay or if you want me to add something more.

That works perfectly! Thank you so much Mille for the quick response!

No problem! Glad I could help!