Testura / Testura.Code

Testura.Code is a wrapper around the Roslyn API and used for generation, saving and compiling C# code. It provides methods and helpers to generate classes, methods, statements and expressions.
MIT License
297 stars 30 forks source link

support for OperatorDeclarationSyntax #65

Closed dszryan closed 4 years ago

dszryan commented 4 years ago

is it possible to generate static bool operator == operations in a class?

MilleBo commented 4 years ago

Hey,

Sadly I haven't implemented override of operators yet. But I can look at it if it's something that you need?

dszryan commented 4 years ago

yes, please. need it for completeness of IEquatable implementation

MilleBo commented 4 years ago

I have uploaded a new version (0.17.0) that hopefully have what you are looking for. You simply specify it when creating the method. For example:

var method = new MethodBuilder("MyMethod")
                .WithModifiers(Modifiers.Public, Modifiers.Static)
                .WithOperatorOverloading(Operators.Equal)
                .WithBody(BodyGenerator.Create())
               .Build();

It should give you:

public static MyMethod operator ==() { }
dszryan commented 4 years ago

thank you :)

dszryan commented 4 years ago

worked perfectly.