-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Binding SG] Dogfood binding source generator in the MAUI codebase #23393
Changes from all commits
478f5e4
649f39d
756232c
5da2611
b4d5927
7a23a77
794a0e0
6cdeb1b
deed704
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/features:"InterceptorsPreviewNamespaces=Microsoft.Maui.Controls.Generated" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,28 +18,6 @@ public static string GenerateCommonCode() => $$""" | |
//------------------------------------------------------------------------------ | ||
#nullable enable | ||
|
||
namespace System.Runtime.CompilerServices | ||
{ | ||
using System; | ||
using System.CodeDom.Compiler; | ||
|
||
{{GeneratedCodeAttribute}} | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] | ||
internal sealed class InterceptsLocationAttribute : Attribute | ||
{ | ||
public InterceptsLocationAttribute(string filePath, int line, int column) | ||
{ | ||
FilePath = filePath; | ||
Line = line; | ||
Column = column; | ||
} | ||
|
||
public string FilePath { get; } | ||
public int Line { get; } | ||
public int Column { get; } | ||
} | ||
} | ||
|
||
namespace Microsoft.Maui.Controls.Generated | ||
{ | ||
using System.CodeDom.Compiler; | ||
|
@@ -73,6 +51,28 @@ private static string GenerateBindingCode(string bindingMethodBody) => $$""" | |
//------------------------------------------------------------------------------ | ||
#nullable enable | ||
|
||
namespace System.Runtime.CompilerServices | ||
{ | ||
using System; | ||
using System.CodeDom.Compiler; | ||
|
||
{{GeneratedCodeAttribute}} | ||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] | ||
file sealed class InterceptsLocationAttribute : Attribute | ||
{ | ||
public InterceptsLocationAttribute(string filePath, int line, int column) | ||
{ | ||
FilePath = filePath; | ||
Line = line; | ||
Column = column; | ||
} | ||
|
||
public string FilePath { get; } | ||
public int Line { get; } | ||
public int Column { get; } | ||
} | ||
} | ||
|
||
Comment on lines
+54
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This might seem like a weird change but we need to make the attribute file-scoped so that there aren't any collisions when there are assemblies with reference between them and they see each others internals (as in the case of |
||
namespace Microsoft.Maui.Controls.Generated | ||
{ | ||
using System; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, if an interceptor is declared outside of a namespace listed here, it will get a C# compiler error.
It sounds like they will rename this to
$(InterceptorsNamespaces)
one day:No problem here, just fyi for later.