F# Public Override of Protected Methods
f#
Solution
Changing accessibility on overrides is not allowed, in either F# or C#. Based on @Endjru's, the best approach is to use a wrapper method that is public to call the protected method;
type Game as game =
inherit Base()
override game.Method =
//...
()
member game.PublicMethod = game.Method
Problem
I've just started learning F# and I'm using it with Monogame to create a simple game to help myself learn the various features of the language. I've hit a roadblock trying to access my game class from outside because the Monogame Game class defines the methods as protected. Trying to do a public override of the method throws an error, telling me setting an accessibility modifiers are not permitted. Base Class Defined in C# ``` public class Base { protected virtual void Method() { //... } } ``` Public Override in F# ``` type Game as game = inherit Base() //Error: Accessibility modifiers are not permitted on overrides or interface implementations override public game.Method = //... () ``` Q: What is the correct way to do a public F# override of an inherited protected C# method?