Altinn / app-lib-dotnet

Libraries used in Altinn Apps
BSD 3-Clause "New" or "Revised" License
8 stars 10 forks source link

Tests that make sure user provided implementations of interfaces have expected ServiceLifetime #779

Open martinothamar opened 2 weeks ago

martinothamar commented 2 weeks ago

Description

Proposal for solution

Related Issue(s)

Verification

Documentation

martinothamar commented 2 weeks ago

Nevermind, this doesn't actually work... Working on a new suggestion

ivarne commented 2 weeks ago

I think the correct approach would be to have a shared factory for all extension point interfaces, that are registered as a Scoped service and retrieves services from a IServiceProvider (that inherits the scope). That way we can also add telemetry span around the GetRequiredService call to catch potentially slow constructors written by users.

danielskovli commented 1 week ago

@martinothamar I don't a useful opinion or contribution to this discussion, unfortunately. It would be great to get a summary of the solution at some point though, after the details have been worked out.

sonarcloud[bot] commented 1 week ago

Quality Gate Failed Quality Gate failed

Failed conditions
24.3% Coverage on New Code (required ≥ 65%)
33.33% Condition Coverage on New Code (required ≥ 65%)

See analysis details on SonarCloud

bjorntore commented 1 week ago

Really like the attribute plus DiagnosticAnalyzer approach. No objections.