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

Nullness issue - Can't cleanly implement INotifyPropertyChanged by publishing an Event #18361

Open
1 of 7 tasks
marklam opened this issue Mar 5, 2025 · 0 comments
Open
1 of 7 tasks
Assignees
Labels
Area-Nullness Issues related to handling of Nullable Reference Types Bug Needs-Triage
Milestone

Comments

@marklam
Copy link

marklam commented Mar 5, 2025

Issue description

A method of implementing INotifyPropertyChanged by publishing an Event now seems impossible to make compile cleanly (?)

namespace Nullness

open System.ComponentModel

type XViewModel() =
    let propertyChanged = Event<PropertyChangedEventHandler, PropertyChangedEventArgs>()
    //let propertyChanged = Event<PropertyChangedEventHandler|null, PropertyChangedEventArgs>()

    interface INotifyPropertyChanged with
        [<CLIEvent>]
        member this.PropertyChanged = propertyChanged.Publish

generates this warning:

1>C:\git\temp\Nullness\Nullness\XViewModel.fs(10,39): warning FS3261: Nullness warning: The types 'System.Delegate' and 'System.Delegate | null' do not have compatible nullability.. See also C:\git\temp\Nullness\Nullness\XViewModel.fs(10,38)-(10,61).

And there doesn't seem to be a way to avoid this.

Choose one or more from the following categories of impact

  • Unexpected nullness warning (false positive in nullness checking, code uses --checknulls and langversion:preview).
  • Missing nullness warning in a case which can produce nulls (false negative, code uses --checknulls and langversion:preview).
  • Breaking change related to older null constructs in code not using the checknulls switch.
  • Breaking change related to generic code and explicit type constraints (null, not null).
  • Type inference issue (i.e. code worked without type annotations before, and applying the --checknulls enforces type annotations).
  • C#/F# interop issue related to nullness metadata.
  • Other (none of the categories above apply).

Operating System

Windows (Default)

What .NET runtime/SDK kind are you seeing the issue on

.NET SDK (.NET Core, .NET 5+)

.NET Runtime/SDK version

Net SD 9.0.200

Reproducible code snippet and actual behavior

namespace Nullness

open System.ComponentModel

type XViewModel() =
    let propertyChanged = Event<PropertyChangedEventHandler, PropertyChangedEventArgs>()
    //let propertyChanged = Event<PropertyChangedEventHandler|null, PropertyChangedEventArgs>()

    interface INotifyPropertyChanged with
        [<CLIEvent>]
        member this.PropertyChanged = propertyChanged.Publish

Possible workarounds

No response

@marklam marklam added Area-Nullness Issues related to handling of Nullable Reference Types Bug Needs-Triage labels Mar 5, 2025
@github-actions github-actions bot added this to the Backlog milestone Mar 5, 2025
@T-Gro T-Gro removed their assignment Mar 10, 2025
@T-Gro T-Gro modified the milestones: Backlog, March 2025 Mar 11, 2025
@T-Gro T-Gro self-assigned this Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Nullness Issues related to handling of Nullable Reference Types Bug Needs-Triage
Projects
Status: New
Development

No branches or pull requests

2 participants