Closed beakona closed 1 year ago
@beakona Thank you for the extended review. This really helps me a lot.
I've created new issues, to make tracking easier.
And I'll close this one.
@beakona
See version 0.0.4 which fixes some issues. See releasenotes for info.
Everything looks good...
See if any of these helps:
@beakona I've fixed some bugs in 0.0.5 and 0.0.6, See releasenotes for details.
@beakona Some more issues are solved. See latest version + releasenotes.
@beakona latest version does fix some more issues. See releasenotes for details.
@StefH Recently I've find out that you can facilitate debugging of the source generator.. https://www.reddit.com/r/csharp/comments/mqzc4r/source_generators_has_anyone_figured_out_the_new/
@beakona
For debugging, there are multiple options:
#if DEBUG - #endif
construction in the Initialize from the Source GeneratorFor option 1: see also my blog https://mstack.nl/blog/20210801-source-generators/
For option 2: Based on the cookbook from source-generators + some other information, I've created a simple NuGet package which can be used to easily test a Source Generator.
See https://github.com/StefH/FluentBuilder/tree/main/src-extensions
There is also the third way where you can directly inspect variables (in 'attached' Visual Studio debugger) during 'compile'. Here is summary from the link I sent 9h ago.
I shared it with you because I find it handy to inspect inner workings of Roslyn ISymbol. I didn't know of this until few days ago..
@beakona Support for indexers has been added to latest release.
I think most issues are solved now.
Closing..
Here are some cases that I find failing and/or cases that is not an error but I pointed them out just to be aware of....
it is not allowed to put simple type name but only full name [ProxyInterfaceGenerator.Proxy(typeof(PITest.Some2.Person))] [ProxyInterfaceGenerator.Proxy(typeof(Person))]
there is a case where _mapper is used but not assigned private readonly IMapper? _mapper; public string? Surname { get => _mapper.Map<string?>(_Instance.Surname); set => _Instance.Surname = _mapper.Map<string?>(value); } public PersonProxy(PITest.Some2.Person instance) { _Instance = instance; }
generated code is not valid when there is no namespace (foreign class is in root scope)
no support for generics public sealed class Person<T>
no support for inner class [ProxyInterfaceGenerator.Proxy(typeof(PITest.Some.Person.Inner))]
output filename clash in case with multiple interfaces with same name but different namespace [ProxyInterfaceGenerator.Proxy(typeof(PITest.Some.Person))] [ProxyInterfaceGenerator.Proxy(typeof(PITest.Some2.Person))]
no support for events... maybe simple forwarders public event EventHandler<EventArgs>? Done { add { _Instance.Done += value; } remove { _Instance.Done -= value; }}
do all reftypes should be mapped? public string? Surname { get => _mapper.Map<string?>(_Instance.Surname); set => _Instance.Surname = _mapper.Map<string?>(value); } public System.Threading.Tasks.Task Method1Async() => _mapper.Map<System.Threading.Tasks.Task>(_Instance.Method1Async());
verbatim names (yes, I know...) public string @object { get; set; }
ref and out are not being forwarded correctly public void Print((int x, int y) position, out int a, in int b, ref int c, int d = 5)
interface methods do not propagate default value for parameters public void Print(int val = 5)
params keyword is not emitted public void Print((int x, int y) position, params int[] d) public void Print((int x, int y) position, int[] d)
no support for indexers public int this[in int a, int b = 5] { ... }
for projects where #nullable is disabled emitting nullable reftype without preprocessor '#nullable enable' would result in compile time error.