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
IReadOnlyCollection as interface param uses Length instead of Count when source is an array #1106
Comments
Thank you for opening this issue, looks like a regression. I‘ll look into it. |
Probably line 208 in |
🎉 This issue has been resolved in version 3.4.0-next.4 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
I dont know should I open new issue or update this, so let's try former: something similar still exists in 3.4.0/next.4. private partial IList<Data.PagerContact>? _MapDtoPagerContactsToPagerContacts(Model.PagerContact[]? source); Actual generated code [global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "3.4.0.0")]
private partial global::System.Collections.Generic.IList<global::Tekelija.TAPaging.Data.PagerContact>? _MapDtoPagerContactsToPagerContacts(global::Tekelija.Model.Dardo.PagerContact[]? source)
{
if (source == null)
return default;
var target = new global::System.Collections.Generic.List<global::Tekelija.TAPaging.Data.PagerContact>(source.Count);
foreach (var item in source)
{
target.Add(_MapPagerContactDtoToPagerContact(item));
}
return target;
} Expected generated code [global::System.CodeDom.Compiler.GeneratedCode("Riok.Mapperly", "3.4.0.0")]
private partial global::System.Collections.Generic.IList<global::Tekelija.TAPaging.Data.PagerContact>? _MapDtoPagerContactsToPagerContacts(global::Tekelija.Model.Dardo.PagerContact[]? source)
{
if (source == null)
return default;
var target = new global::System.Collections.Generic.List<global::Tekelija.TAPaging.Data.PagerContact>(source.Length);
foreach (var item in source)
{
target.Add(_MapPagerContactDtoToPagerContact(item));
}
return target;
}
|
@kockicica I cannot reproduce it with the latest next release 😞 Sometimes when upgrading a source generator package the IDE does not correctly regenerate the code with the new source generator. Have you restarted your IDE after upgrading the Mapperly package? |
Oh' I've restarted everything, several times - without effect unfortunately. 😄 Here's is a simple example: https://github.com/kockicica/mapperly-test |
Thank you for the repro, now I got it. The issue still exists when the parameter of the user defined mapping method is an array. I onl tested enumerables/arrays as object properties which is fixed. I‘ll look into it in the next days. |
🎉 This issue has been resolved in version 3.4.0-next.5 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This is hopefully really fixed in 3.4.0-next.5. Could you (@kockicica) verify this? |
Just tried and yes, i think that we can finally mark this as resolved for good. 😃 Thanks a lot. |
🎉 This issue has been resolved in version 3.4.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Describe the bug
Enumerable mapping methods with interface parameters uses 'Length', property that does not exist on System.Collections.Generic.IReadOnlyCollection when source is an array
Declaration code
Actual generated code
Expected generated code
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: