-
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
Error thrown when accessing resource values with OnPlatform from Resource Dictionary #16494
Comments
What is the value of |
Hi @sbxamdev. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
Hi, Its an BTW It is working in my existing Xamarin.Forms App. |
but but but... OnPlatform declare an implicit cast operator to T, so it should work |
I can reproduce this |
Ok... there's no bug here, but you need to hint the C# compiler. From the compiler point of view, value is of type object, so it can not generate code that invokes the implicit cast operator defined in OnPlatform. you can do it by changing your code to one of this 3 options
|
Description
Hi guys,
From MAUI's default app project, I just added a Resource item having double as the type and have separate values per platform.
![image](https://private-user-images.githubusercontent.com/107564640/257791961-9634948e-b0a5-4e5d-8ee7-c4a1a7cd828c.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI0ODU0MDcsIm5iZiI6MTcyMjQ4NTEwNywicGF0aCI6Ii8xMDc1NjQ2NDAvMjU3NzkxOTYxLTk2MzQ5NDhlLWIwYTUtNGU1ZC04ZWU3LWM0YTFhN2NkODI4Yy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwMVQwNDA1MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02NzcyMjI4MzVkMDIzZTJkYTdhYzZkYTU3OWNlYmYyODNmMTg2MTRmNGIwY2MxOTQzODU3MmQ3ODEwZTYzNzkxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.IEZe05nfr39Tk1WIUOG0zdLEGxUP_LBqHgEOcrGfsLQ)
Screenshot:
I dont have any issues in using it from xaml, however when I access it from c#, an error is thrown
![image](https://private-user-images.githubusercontent.com/107564640/257792561-0bc2e13a-4896-40dc-be85-de65385d5947.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI0ODU0MDcsIm5iZiI6MTcyMjQ4NTEwNywicGF0aCI6Ii8xMDc1NjQ2NDAvMjU3NzkyNTYxLTBiYzJlMTNhLTQ4OTYtNDBkYy1iZTg1LWRlNjUzODVkNTk0Ny5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgwMVQwNDA1MDdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jY2I2NTZkMGM3NGZkMDUwMmFhZTk5Zjk5MWI0MmQzNTEwYzc5YmNlYTgxN2ZiOTQ5MjdmMmFmMzA4MTZkMjE4JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9._852hwzN8cVt-ZCrAKQCyO49CAJZyPKKjkd027OtWec)
Screenshot:
Additional Note: Trying the above c# code for resource that has single value for both platform works fine (Not OnPlatform syntax).
Please can anyone help? Thanks in advance, will greatly appreciate it. :)
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
7.0.49
Last version that worked well
6.0
Affected platforms
Android, I was not able test on other platforms
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: