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

Add support for transforming Nullable, ValueTuple (HAST-239) #62

Open
sarahelsaig opened this issue Dec 18, 2021 · 3 comments
Open

Add support for transforming Nullable, ValueTuple (HAST-239) #62

sarahelsaig opened this issue Dec 18, 2021 · 3 comments

Comments

@sarahelsaig
Copy link
Member

sarahelsaig commented Dec 18, 2021

Currently you are unable to work with nullable structs, for example a method that returns Unum? will throw "The declaration of the type System.Nullable`1[[Lombiq.Arithmetics.Unum]] couldn't be found." error in the TypeConverter. Also null-coalescing operations need to be tested.
Similarly, (int A, int B) Foo() => (1, 1); will throw "The declaration of the type System.ValueTuple`2[[System.Int32],[System.Int32]] couldn't be found.".

Although not a bug, both are commonly used features of modern C# where lack of support will hinder adoption.

Jira issue

@sarahelsaig
Copy link
Member Author

I'm not sure if this is related or a separate issue, but also if you return an array from a method instead of a property it won't work even if the two are functionally equivalent. For example Quire.Segments is an array returning property which is not suggested for performance reasons. But if I replace it with a ulong[] GetSegments() => _segments; method, I will get the The length of the array holder System.Void Lombiq.Arithmetics.Quire::.ctor(System.UInt64[],System.UInt16).Lombiq.Arithmetics.Quire.GetSegments (@this)[82..87) couldn't be statically determined. error. Checking if a method returns a trivial reference could resolve that problem.

@Piedone
Copy link
Member

Piedone commented Dec 19, 2021

The second one is a different issue. However, fixing CA1819 should rather be ulong[] GetSegments() => _segments.Clone(); which would need specific support on top of that.

@sarahelsaig
Copy link
Member Author

Okay, then I will open a new issue for it here. As for your suggestion, wouldn't the cloning cause unnecessary overhead? If possible passing an immutable reference via IReadOnlyList<ulong> GetSegments() => _segments; makes more sense to me. Then the consumer can clone via .ToArray() if that's actually what they need.

@github-actions github-actions bot changed the title Add support for transforming Nullable, ValueTuple Add support for transforming Nullable, ValueTuple (HAST-239) Sep 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants