Merge pull request #32344 from timdeschryver/fix-rdg-highlights
fix RDG highlights after code samples updatepull/32342/head
commit
f5b30ee48f
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.`
|
||||
|
|
Loading…
Reference in New Issue