-
Notifications
You must be signed in to change notification settings - Fork 520
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
[Generator] The generator creates not compilable code when a selector has the word Handle in it. #18645
Milestone
Comments
mandel-macaque
added a commit
to mandel-macaque/xamarin-macios
that referenced
this issue
Aug 6, 2023
Fixes dotnet#18645 The way the generator names private fields for selectors results on not compilable code when there are two selectoors A and B such that selector B == AHandle. That is, if selector A is "user", selector B will be "userHandle". This happens because Handle is quite a common postfix in security when working with user accounts (userHandler and others) and we need to ensure that the Handle postfix added by the generator is unique. As stated in the bug we could try to fix this by keeping track of the variables in the context in wich the generator is creating code. The problem with such approach is that it will make very hard to predict the name of the fields making the manual code harder to write. The PR contains examples of such manual code. To fix the situation we have moved from using Handle to XHandle as a postfix in the field names whihc reduces the chances of finding a similar corner case in the future. A test has been added to show the case in which we found the bug. Fixes dotnet#18645
mandel-macaque
added a commit
to mandel-macaque/xamarin-macios
that referenced
this issue
Aug 6, 2023
Fixes dotnet#18645 The way the generator names private fields for selectors results on not compilable code when there are two selectoors A and B such that selector B == AHandle. That is, if selector A is "user", selector B will be "userHandle". This happens because Handle is quite a common postfix in security when working with user accounts (userHandler and others) and we need to ensure that the Handle postfix added by the generator is unique. As stated in the bug we could try to fix this by keeping track of the variables in the context in wich the generator is creating code. The problem with such approach is that it will make very hard to predict the name of the fields making the manual code harder to write. The PR contains examples of such manual code. To fix the situation we have moved from using Handle to XHandle as a postfix in the field names whihc reduces the chances of finding a similar corner case in the future. A test has been added to show the case in which we found the bug. Fixes dotnet#18645
mandel-macaque
added a commit
that referenced
this issue
Aug 8, 2023
vs-mobiletools-engineering-service2
pushed a commit
to vs-mobiletools-engineering-service2/xamarin-macios
that referenced
this issue
Aug 8, 2023
Fixes dotnet#18645 The way the generator names private fields for selectors results on not compilable code when there are two selectoors A and B such that selector B == AHandle. That is, if selector A is "user", selector B will be "userHandle". This happens because Handle is quite a common postfix in security when working with user accounts (userHandler and others) and we need to ensure that the Handle postfix added by the generator is unique. As stated in the bug we could try to fix this by keeping track of the variables in the context in wich the generator is creating code. The problem with such approach is that it will make very hard to predict the name of the fields making the manual code harder to write. The PR contains examples of such manual code. To fix the situation we have moved from using Handle to XHandle as a postfix in the field names whihc reduces the chances of finding a similar corner case in the future. A test has been added to show the case in which we found the bug. Fixes dotnet#18645
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given the following example binding:
The generator will create two private fields in the generated class that use the same name resulting in the following error:
The reason for this is that we have the word handle and the ned of the selector form the property. Because we do not keep track of the variable names in the scope, this results a duplicated variable name. There are 2 ways to fix this:
Approach 1 is easier for several reasons:
The text was updated successfully, but these errors were encountered: