F#编译器:类型实例化涉及byref类型

F#编译器:类型实例化涉及byref类型,f#,byref,F#,Byref,我有一个问题和解决办法。我不明白为什么这个解决方案有效 下面是一些代码,它通过消息“类型实例化涉及byref类型”来中断F#编译器: 这就完成了它应该做的一切(即,只有当有外部登录可用时,UI才会显示分隔符)。我不明白的是,为什么这一更改应该修复编译 编译器引用的类型实例化是否创建了updateExternalLoginProperty函数?为什么将其转换为成员变量可以避免这种非法的类型实例化 作为一个附带问题,nameof什么时候会出现在F#中?这些神奇的琴弦让我伤心 更新 根据ildjam的

我有一个问题和解决办法。我不明白为什么这个解决方案有效

下面是一些代码,它通过消息“类型实例化涉及byref类型”来中断F#编译器:

这就完成了它应该做的一切(即,只有当有外部登录可用时,UI才会显示分隔符)。我不明白的是,为什么这一更改应该修复编译

编译器引用的类型实例化是否创建了
updateExternalLoginProperty
函数?为什么将其转换为成员变量可以避免这种非法的类型实例化

作为一个附带问题,
nameof
什么时候会出现在F#中?这些神奇的琴弦让我伤心

更新

根据ildjam的回答(元组中不可能有byref),我返回到
let
绑定,只有三个参数,而不是一个:

let updateExternalLoginProperty (isEnabled: bool byref) (value: bool) (name: string) =
    let anyExternalLoginEnabledBeforePropertyIsSet = this.AnyExternalLoginEnabled
    this.RaiseAndSetIfChanged(&isEnabled, value, name) |> ignore
    if (this.AnyExternalLoginEnabled <> anyExternalLoginEnabledBeforePropertyIsSet) then this.RaisePropertyChanged("AnyExternalLoginEnabled")

member this.FacebookLoginEnabled with get() = facebookLoginEnabled  and set(value) = updateExternalLoginProperty &facebookLoginEnabled value "FacebookLoginEnabled"
member this.GoogleLoginEnabled with get() = googleLoginEnabled and set(value) = updateExternalLoginProperty &googleLoginEnabled value "GoogleLoginEnabled"
member this.MicrosoftLoginEnabled with get() = microsoftLoginEnabled and set(value) = updateExternalLoginProperty &microsoftLoginEnabled value "MicrosoftLoginEnabled"
member this.TwitterLoginEnabled with get() = twitterLoginEnabled and set(value) = updateExternalLoginProperty &twitterLoginEnabled value "TwitterLoginEnabled"
member this.AzureActiveDirectoryLoginEnabled with get() = azureActiveDirectoryLoginEnabled and set(value) = updateExternalLoginProperty &azureActiveDirectoryLoginEnabled value "AzureActiveDirectoryLoginEnabled"
member this.AnyExternalLoginEnabled with get() = this.FacebookLoginEnabled || this.GoogleLoginEnabled || this.MicrosoftLoginEnabled || this.TwitterLoginEnabled || this.AzureActiveDirectoryLoginEnabled
let updateExternalLoginProperty(isEnabled:bool byref)(值:bool)(名称:string)=
让anyExternalLoginEnabledBeforepropertySet=this.AnyExternalLoginEnabled
this.RaiseAndSetIfChanged(&isEnabled,value,name)|>忽略
如果(this.AnyExternalLoginEnabled AnyExternalLoginEnabled BeforRepropertySet)则this.RaiseProperty已更改(“AnyExternalLoginEnabled”)
成员this.FacebookLoginEnabled,get()=FacebookLoginEnabled,set(value)=updateExternalLogginProperty&FacebookLoginEnabled值“FacebookLoginEnabled”
成员this.GoogleLoginEnabled,get()=GoogleLoginEnabled,set(value)=UpdateExternalLogginProperty&GoogleLoginEnabled值“GoogleLoginEnabled”
成员this.MicrosoftLoginEnabled,get()=MicrosoftLoginEnabled,set(value)=updateExternalLogginProperty&MicrosoftLoginEnabled值“MicrosoftLoginEnabled”
成员this.TwitterLoginEnabled,get()=TwitterLoginEnabled,set(value)=updateExternalLogginProperty&TwitterLoginEnabled值“TwitterLoginEnabled”
成员this.AzureActiveDirectoryLoginEnabled,get()=AzureActiveDirectoryLoginEnabled并设置(值)=updateExternalLoginProperty&AzureActiveDirectoryLoginEnabled值“AzureActiveDirectoryLoginEnabled”
成员this.anyExternalLogineEnabled with get()=this.FaceBookLogineEnabled | | | | this.GoogleLogineEnabled | | | this.MicrosoftLogineEnabled | | this.TwitterLogineEnabled | this.AzureActiveDirectoryLogineEnabled

这也行得通。这是一个有趣的区别:成员变量有三个参数;原始的
let
绑定只有一个
tuple
参数。

成员private this.UpdateExternalLoginProperty
接受三个参数,但
let UpdateExternalLoginProperty
接受一个参数–类型为
bool byref*bool*string
的元组,对于元组元素,
\ubyref
是不合法的。这是有效的。我会更新我的问题。谢谢
member private this.UpdateExternalLoginProperty(isEnabled: bool byref, value: bool, name: string) =
    let anyExternalLoginEnabledBeforePropertyIsSet = this.AnyExternalLoginEnabled
    this.RaiseAndSetIfChanged(&isEnabled, value, name) |> ignore
    if (this.AnyExternalLoginEnabled <> anyExternalLoginEnabledBeforePropertyIsSet) then this.RaisePropertyChanged("AnyExternalLoginEnabled")

member this.FacebookLoginEnabled with get() = facebookLoginEnabled  and set(value) = this.UpdateExternalLoginProperty(&facebookLoginEnabled, value, "FacebookLoginEnabled")
member this.GoogleLoginEnabled with get() = googleLoginEnabled and set(value) = this.UpdateExternalLoginProperty(&googleLoginEnabled, value, "GoogleLoginEnabled") |> ignore
member this.MicrosoftLoginEnabled with get() = microsoftLoginEnabled and set(value) = this.UpdateExternalLoginProperty(&microsoftLoginEnabled, value, "MicrosoftLoginEnabled") |> ignore
member this.TwitterLoginEnabled with get() = twitterLoginEnabled and set(value) = this.UpdateExternalLoginProperty(&twitterLoginEnabled, value, "TwitterLoginEnabled") |> ignore
member this.AzureActiveDirectoryLoginEnabled with get() = azureActiveDirectoryLoginEnabled and set(value) = this.UpdateExternalLoginProperty(&azureActiveDirectoryLoginEnabled, value, "AzureActiveDirectoryLoginEnabled") |> ignore
member this.AnyExternalLoginEnabled with get() = this.FacebookLoginEnabled || this.GoogleLoginEnabled || this.MicrosoftLoginEnabled || this.TwitterLoginEnabled || this.AzureActiveDirectoryLoginEnabled
let updateExternalLoginProperty (isEnabled: bool byref) (value: bool) (name: string) =
    let anyExternalLoginEnabledBeforePropertyIsSet = this.AnyExternalLoginEnabled
    this.RaiseAndSetIfChanged(&isEnabled, value, name) |> ignore
    if (this.AnyExternalLoginEnabled <> anyExternalLoginEnabledBeforePropertyIsSet) then this.RaisePropertyChanged("AnyExternalLoginEnabled")

member this.FacebookLoginEnabled with get() = facebookLoginEnabled  and set(value) = updateExternalLoginProperty &facebookLoginEnabled value "FacebookLoginEnabled"
member this.GoogleLoginEnabled with get() = googleLoginEnabled and set(value) = updateExternalLoginProperty &googleLoginEnabled value "GoogleLoginEnabled"
member this.MicrosoftLoginEnabled with get() = microsoftLoginEnabled and set(value) = updateExternalLoginProperty &microsoftLoginEnabled value "MicrosoftLoginEnabled"
member this.TwitterLoginEnabled with get() = twitterLoginEnabled and set(value) = updateExternalLoginProperty &twitterLoginEnabled value "TwitterLoginEnabled"
member this.AzureActiveDirectoryLoginEnabled with get() = azureActiveDirectoryLoginEnabled and set(value) = updateExternalLoginProperty &azureActiveDirectoryLoginEnabled value "AzureActiveDirectoryLoginEnabled"
member this.AnyExternalLoginEnabled with get() = this.FacebookLoginEnabled || this.GoogleLoginEnabled || this.MicrosoftLoginEnabled || this.TwitterLoginEnabled || this.AzureActiveDirectoryLoginEnabled