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

IXamlMethod Generic definition #112

Closed
workgroupengineering opened this issue Apr 10, 2024 · 3 comments · Fixed by #120
Closed

IXamlMethod Generic definition #112

workgroupengineering opened this issue Apr 10, 2024 · 3 comments · Fixed by #120

Comments

@workgroupengineering
Copy link
Contributor

HI,
in the pr AvaloniaUI/Avalonia#15274. I have need to retrieve Interactive.AddHandler<TEventArgs> method. To do this, I tried using IXamlType.FindMethod and checking if the method name is AddHandler`1 without success.

After investigation I found following workaround

https://github.com/AvaloniaUI/Avalonia/blob/3f82e64c469198d3e80557b7c3c5071a8c29d806/src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/Transformers/AvaloniaXamlIlWellKnownTypes.cs#L155-L163

                AddHandlerT = Interactive.FindMethod(m => m.IsPublic
                    && !m.IsStatic
                    && m.Name == "AddHandler"
                    && m.Parameters.Count == 4
                    && RoutedEvent.IsAssignableFrom(m.Parameters[0])
                    && m.Parameters[0].GenericArguments?.Count == 1 // This is specific this case  workaround to check is generici method
                    && (cfg.WellKnownTypes.Delegate).IsAssignableFrom(m.Parameters[1])
                    && m.Parameters[2].IsEnum
                    && m.Parameters[3].Equals(cfg.WellKnownTypes.Boolean) == true

I would like to make a PR that makes it easier to identify the generic method. There are a few possibilities:

  • Add `n to the end of name of generic method, where n is number of generic arguments
  • Add property IsGenericDef to IXamlMethod
  • Expose GenericArguments and GenericParameters
  • All three previous proposed solutions

What do you think is the best solution?

@kekekeks
Copy link
Owner

The general idea of our type system abstraction is to mirror SRE APIs, since those are the most convenient to use. So 2+3 would make the most sense.

@workgroupengineering
Copy link
Contributor Author

Do I add 2+3 to IXamlMethod or create IXamlGenericMethod?

@maxkatz6
Copy link
Collaborator

I would say, adding these to IXamlMethod.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants