Skip to content

Unable to implement abstract class #3540

Closed

Description

@saul
namespace Microsoft.VisualStudio.FSharp.Editor.Tests.Roslyn

open Microsoft.CodeAnalysis.Options
open System.Collections.Immutable

type TestOptionSet(?values: ImmutableDictionary<OptionKey, obj>) =
    inherit OptionSet()

    let values = values |> Option.defaultValue ImmutableDictionary.Empty

    override __.GetOption(optionKey: OptionKey) =
        values.[optionKey]

    override __.WithChangedOption(optionAndLanguage: OptionKey, value: obj) =
        upcast TestOptionSet(values.SetItem(optionAndLanguage, value))

    // The member that I cannot override (FS0855)
    override __.GetChangedOptions(optionSet: OptionSet) : seq<OptionKey> =
        values
        |> Seq.filter (fun (KeyValue(k,v)) ->
            optionSet.GetOption(k) <> v
            )
        |> Seq.map (fun (KeyValue(k,_)) -> k)     

I get the error message:

FS0855	No abstract or interface member was found that corresponds to this override

If I remove the override keyword from the GetChangedOptions member, I then get the following error:

FS0365	No implementation was given for 'OptionSet.GetChangedOptions(optionSet: OptionSet) : System.Collections.Generic.IEnumerable<OptionKey>'

I believe this may have something to do with the fact that GetChangedOptions is internal, but I can't specify that with the override keyword, otherwise I get:

FS0941	Accessibility modifiers are not permitted on overrides or interface implementations

This is currently blocking me completing #3313

Activity

  1. majocha commented on Sep 2, 2017

    @majocha
    Contributor

    image
    This looks not F# specific 😞 but rather a Roslyn issue.

  2. majocha commented on Sep 2, 2017

    @majocha
    Contributor

    My guess is you'd need an additional InternalsVisibleToFSharp in Roslyn to implement this class.

  3. dsyme commented on Sep 4, 2017

    @dsyme
    Contributor
  4. Pilchie commented on Sep 11, 2017

    @Pilchie
    Member

    Tags @jasonmalinowski and @sharwell on this one.

    (Sorry for the delay, was on vacation when this hit my inbox).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions