Open simonrozsival opened 9 months ago
One potential issue I see in:
interface IQueryAttributable
{
void ApplyQueryAttributes(IDictionary<string, object?> query);
void ApplyQueryAttributes(IDictionary<string, object?> query, IDictionary<string, object?>? oldQuery) => ApplyQueryAttributes(query);
}
If we add the new member, we don't break code now, but then we are going to always need both members implemented. If I want the new API with 2 params, we can implement it, but we will still need the old API.
I wonder if a new interface is better, and also not use a plain dictionary but rather some ApplyQueryAttributesEventArgs
type thing:
class ApplyQueryAttributesEventArgs
{
public IDictionary<string, object?> NewQuery { get; }
public IDictionary<string, object?>? OldQuery { get; }
// potentially new members to help
public bool IsFirstBinding { get; }
}
Motivation
ShellContent applies query properties via reflection. Since we can't fix this code just with
[DynamicallyAccesseMebers(...)]
attributes, we need a different solution.The idea is to source-generate code equivalent to the reflection-based code. This would make this functionality not only trimmable and AOT-compatible, but also a bit faster.
Source generator specification
[QueryProperty]
attribute applied to itIQueryAttributable
&
or?
)[QueryProperty]
IQueryAttributable.ApplyQueryAttributes
IQueryAttributable
implementation to the classApplyQueryAttributes
method[QueryProperty]
attributeConvert.ChangeType
?Example
Notes and questions
null
(no matter what the actual type of the property is).IQueryAttributable
interface:QueryAttributableHelpers
for the repeating code patterns.QueryAttributableHelpers
as a new public API and ship it with MAUI.