I have encountered a seemingly "weird" situation. Repro:
- Create an F# library
- Add a component class type, inheriting ComponentBase
- Override BuildRenderTree
//Comp1Base.fs
namespace ClassLibrary1
open Microsoft.AspNetCore.Components
type Comp1Base() =
inherit ComponentBase()
override __.BuildRenderTree(builder) = base.BuildRenderTree(builder)
- Create a Blazor WASM project (C#) and reference the F# project
- Add a razor component to this project and inherit from the F# base component
//Comp1.razor
@inherits ClassLibrary1.Comp1Base
Now the Blazor project doesn't compile:
Error CS0507 'Comp1.BuildRenderTree(RenderTreeBuilder)': cannot change access modifiers when overriding 'public' inherited member 'Comp1Base.BuildRenderTree(RenderTreeBuilder)' BlazorApp1 C:\Temp\qwerty\BlazorApp1\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Comp1_razor.g.cs 85 N/A
ILSpy shows that the overridden member in F# is public, while the base member is protected:
Is there a way to make it work?