Skip to content
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

[LayoutBindings] LayoutBindings: 'PreserveAttribute' is obsolete warnings #8529

Merged
merged 8 commits into from
Mar 27, 2024

Commits on Mar 4, 2024

  1. [LayoutBindings] LayoutBindings: 'PreserveAttribute' is obsolete warn…

    …ings
    
    Fixes dotnet#7480
    
    * Remove the use of `PreserveAttribute` as we no longer support Xamarin
      Classic in main.
    * Add #pragma and code comments to fix certain CS* warnings which are
      emitted by the C# compiler.
    * Ignore a bunch of other warnings in the unit test.
    dellis1972 committed Mar 4, 2024
    Configuration menu
    Copy the full SHA
    bf44afd View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3dc5ca7 View commit details
    Browse the repository at this point in the history
  3. Fix some tests

    dellis1972 committed Mar 4, 2024
    Configuration menu
    Copy the full SHA
    04103bc View commit details
    Browse the repository at this point in the history
  4. Fix up some more

    dellis1972 committed Mar 4, 2024
    Configuration menu
    Copy the full SHA
    f216115 View commit details
    Browse the repository at this point in the history
  5. Revert this change

    dellis1972 committed Mar 4, 2024
    Configuration menu
    Copy the full SHA
    84cd076 View commit details
    Browse the repository at this point in the history

Commits on Mar 19, 2024

  1. Add nullability info to LayoutBinding.cs

    Context: dotnet#8529 (comment)
    
    When building a project that uses layout bindings, multiple nullability
    warnings are emitted from `LayoutBinding.cs`:
    
    	…/LayoutBinding.cs(16,98): warning CS8625: Cannot convert null literal to non-nullable reference type.
    	…/LayoutBinding.cs(22,90): warning CS8625: Cannot convert null literal to non-nullable reference type.
    	…/LayoutBinding.cs(16,13): warning CS8618: Non-nullable field 'boundView' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
    	…/LayoutBinding.cs(22,13): warning CS8618: Non-nullable field 'boundActivity' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
    	…/LayoutBinding.cs(35,11): warning CS8600: Converting null literal or possible null value to non-nullable type.
    	…/LayoutBinding.cs(37,11): warning CS8600: Converting null literal or possible null value to non-nullable type.
    	…/LayoutBinding.cs(79,56): warning CS8602: Dereference of a possibly null reference.
    	…/LayoutBinding.cs(79,56): warning CS8603: Possible null reference return.
    	…/LayoutBinding.cs(79,56): warning CA1422: This call site is reachable on: 'Android' 21.0 and later. 'Activity.FragmentManager' is obsoleted on: 'Android' 28.0 and later. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1422)
    	…/LayoutBinding.cs(79,56): warning CA1422: This call site is reachable on: 'Android' 21.0 and later. 'FragmentManager.FindFragmentById<T>(int)' is obsoleted on: 'Android' 28.0 and later (This class is obsoleted in this android platform). (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1422)
    
    Update `LayoutBinding.cs` to include nullability annotations.
    Now, no warnings are emitted when
    `$(AndroidGenerateLayoutBindings)`=true.
    jonpryor committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    c6b506d View commit details
    Browse the repository at this point in the history

Commits on Mar 20, 2024

  1. Configuration menu
    Copy the full SHA
    cc42d79 View commit details
    Browse the repository at this point in the history
  2. #nullable enable

    The `SuccessfulAndroidXApp` test was failing, as it asserted no
    warnings, yet it had warnings:
    
        …\LayoutBinding.cs(61,56): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(61,72): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(79,76): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(79,95): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(88,86): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(88,105): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(16,74): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(22,66): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(12,11): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(13,7): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(14,30): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
        …\LayoutBinding.cs(33,5): warning CS8632: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
    
    Slap on a `#nullable enable` so that we can reliably use
    nullable reference types within `LayoutBinding.cs`.
    jonpryor committed Mar 20, 2024
    Configuration menu
    Copy the full SHA
    6d0f448 View commit details
    Browse the repository at this point in the history