Merge pull request #32344 from timdeschryver/fix-rdg-highlights

fix RDG highlights after code samples update
pull/32342/head
Rick Anderson 2024-04-17 08:05:06 -10:00 committed by GitHub
commit f5b30ee48f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 9 deletions

View File

@ -23,13 +23,13 @@ This diagnostic is emitted by the [Request Delegate Generator](/aspnet/core/fund
The implementation of surrogate binding via the [`[AsParameters]`](xref:Microsoft.AspNetCore.Http.AsParametersAttribute) attribute in minimal APIs only supports types that are not nullable.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg10/Program.cs" id="snippet_1" highlight="7":::
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg10/Program.cs" id="snippet_1" highlight="13":::
## How to fix violations
Declare the parameter as non-nullable.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg10/Program.cs" id="snippet_1f" highlight="7":::
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg10/Program.cs" id="snippet_1f" highlight="13":::
## When to suppress warnings

View File

@ -22,14 +22,13 @@ This diagnostic is emitted by the Request Delegate Generator when an endpoint co
Endpoints that use generic type parameters are not supported. The endpoints within `MapEndpoints` produce this diagnostic because of the generic `<T>` parameter.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg11/Program.cs" id="snippet_1" highlight="9-20":::
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg11/Program.cs" id="snippet_1" highlight="16":::
## How to fix violations
Remove the generic type from endpoints.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg11/Program.cs" id="snippet_1f" highlight="9-20":::
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg11/Program.cs" id="snippet_1f" highlight="16":::
## When to suppress warnings

View File

@ -23,14 +23,14 @@ This diagnostic is emitted by the Request Delegate Generator when an endpoint co
Endpoints that use an inaccessible type (`private` or `protected`) are not supported.
The endpoints within `MapEndpoints` produce this diagnostic because of the `Todo` type has the `private` accessibility modifiers.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg12/Program.cs" id="snippet_1" highlight="9-20, 22":::
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg12/Program.cs" id="snippet_1" highlight="16-27, 29":::
## How to fix violations
When applicable, set the target parameter type with a friendly accessibility.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg12/Program.cs" id="snippet_1f" highlight="9-20, 22":::
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg12/Program.cs" id="snippet_1f" highlight="17-28, 30":::
## When to suppress warnings

View File

@ -22,13 +22,14 @@ This diagnostic is emitted by the [Request Delegate Generator](/aspnet/core/fund
ASP.NET Core supports resolving keyed and non-keyed services via [dependency injection](xref:fundamentals/dependency-injection). It's ***not*** feasible to resolve a service as both keyed and non-keyed. The following code produces the diagnostic and throws a run time error with the same message:
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg13/Program.cs" id="snippet_1" highlight="8":::
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg13/Program.cs" id="snippet_1" highlight="14":::
## How to fix violations
Resolve the target parameter as either a keyed or non-keyed service.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg13/Program.cs" id="snippet_1f" highlight="10,15,20":::
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg13/Program.cs" id="snippet_1f" highlight="16,21,26":::
## When to suppress warnings
This warning should ***not*** be suppressed. Suppressing the warning leads to a [NotSupportedException](/dotnet/api/system.notsupportedexception) runtime exception `The FromKeyedServicesAttribute is not supported on parameters that are also annotated with IFromServiceMetadata.`