sentry-dotnet icon indicating copy to clipboard operation
sentry-dotnet copied to clipboard

.NET 6 Minimal Api with F# doesn't suggest the correct 'open'

Open lucas-zimerman opened this issue 3 years ago • 5 comments

When using the following snippet

open System
open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.Hosting

[<EntryPoint>]
let main args =
    let builder = WebApplication.CreateBuilder(args)
    builder.WebHost.UseSentry()
    
    let app = builder.Build()
    app.UseSentryTracing()
    app.MapGet("/", Func<string>(fun () -> "Hello World!")) |> ignore

    app.Run()

    0 // Exit code

F# will complain that the type 'ConfigureWebHostBuilder' does not define the field, constructor or member 'UseSentry'.

Weirdly enough, the problem gets solved when including open Microsoft.AspNetCore.Hosting

lucas-zimerman avatar Feb 01 '22 18:02 lucas-zimerman

This method is defined on:

https://github.com/getsentry/sentry-dotnet/blob/35b72f296ea000bfc5ee31a7264701cffff39437/src/Sentry.AspNetCore/SentryWebHostBuilderExtensions.cs#L9

bruno-garcia avatar Feb 01 '22 20:02 bruno-garcia

Quick win here is to add the open Microsoft.AspNetCore.Hosting // Make sure to open this namespace to the install wizard and docs

bruno-garcia avatar Feb 01 '22 20:02 bruno-garcia

More generally, this issue would be resolved if we had extended the generic host: https://github.com/getsentry/sentry-dotnet/pull/1015

bruno-garcia avatar Feb 01 '22 20:02 bruno-garcia

@lucas-zimerman by any chance did you fix it already?

image

bruno-garcia avatar Mar 10 '22 20:03 bruno-garcia

@bruno-garcia The doc got updated , Ideally we could create another issue to expand the generic host and close this one.

lucas-zimerman avatar Mar 11 '22 17:03 lucas-zimerman