-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Trimming] Use new feature switch definition attribute and enable analyzers in Controls.Core.csproj #21621
Merged
jonathanpeppers
merged 12 commits into
dotnet:net9.0
from
simonrozsival:use-new-feature-switch-definition-attribute
Apr 17, 2024
Merged
[Trimming] Use new feature switch definition attribute and enable analyzers in Controls.Core.csproj #21621
Changes from 6 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
589ee60
Use new FeatureSwitchDefinition attributes instead of ILLink substitu…
simonrozsival d4fb42a
Update comment
simonrozsival a44b5a9
Update Controls
simonrozsival c97e876
Update Compatibility
simonrozsival 78d326f
Disable analyzers in Controls.Core on Tizen
simonrozsival 651be65
Skip warning on Windows
simonrozsival b6a7cb1
Fix TODO
simonrozsival 8e60bf5
Add RUC attributes to NativeBindingExtensions
simonrozsival 085753b
Add RUC attributes to NativeBindingService
simonrozsival c550246
Add missing usings
simonrozsival 8a4e8aa
Add comment explaining why DoNothing moved from Binding to MultiBinding
simonrozsival b65b299
Update comment
simonrozsival File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/Compatibility/Core/src/Android/Extensions/NativeBindingExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Reflection; | ||
|
||
namespace Microsoft.Maui.Controls | ||
{ | ||
internal static class BindingExpressionHelper | ||
{ | ||
static readonly Type[] DecimalTypes = { typeof(float), typeof(decimal), typeof(double) }; | ||
|
||
internal static bool TryConvert(ref object value, BindableProperty targetProperty, Type convertTo, bool toTarget) | ||
{ | ||
if (value == null) | ||
return !convertTo.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(convertTo) != null; | ||
try | ||
{ | ||
if ((toTarget && targetProperty.TryConvert(ref value)) || (!toTarget && convertTo.IsInstanceOfType(value))) | ||
return true; | ||
} | ||
catch (InvalidOperationException) | ||
{ //that's what TypeConverters ususally throw | ||
return false; | ||
} | ||
|
||
object original = value; | ||
try | ||
{ | ||
convertTo = Nullable.GetUnderlyingType(convertTo) ?? convertTo; | ||
|
||
var stringValue = value as string ?? string.Empty; | ||
// see: https://bugzilla.xamarin.com/show_bug.cgi?id=32871 | ||
// do not canonicalize "*.[.]"; "1." should not update bound BindableProperty | ||
if (stringValue.EndsWith(CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator, StringComparison.Ordinal) && DecimalTypes.Contains(convertTo)) | ||
{ | ||
value = original; | ||
return false; | ||
} | ||
|
||
// do not canonicalize "-0"; user will likely enter a period after "-0" | ||
if (stringValue == "-0" && DecimalTypes.Contains(convertTo)) | ||
{ | ||
value = original; | ||
return false; | ||
} | ||
|
||
value = Convert.ChangeType(value, convertTo, CultureInfo.CurrentCulture); | ||
|
||
return true; | ||
} | ||
catch (Exception ex) when (ex is InvalidCastException || ex is FormatException || ex is InvalidOperationException || ex is OverflowException) | ||
{ | ||
value = original; | ||
return false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm not very happy we have these
UnconditionalSuppressMessage
here. I think in this case it might be worth putting[RequiresUnreferencedCode]
on theINativeBindingService.TrySetBinding(object, string, BindingBase)
and all the classes that implement it.