33 строки
1.0 KiB
Markdown
33 строки
1.0 KiB
Markdown
# PC002: API not available in .NET Framework 4.6.1
|
|
|
|
## Cause
|
|
|
|
You're calling an API in .NET Standard that isn't available in the .NET Framework
|
|
4.6.1.
|
|
|
|
## Rule description
|
|
|
|
While the .NET Framework 4.6.1 is treated by NuGet as implementing .NET Standard
|
|
2.0, it doesn't fully implement it. This trade-off is explained in the
|
|
[.NET Standard][netfx-netstandard] specification.
|
|
|
|
## How to fix violations
|
|
|
|
You cannot reasonably guard your code against missing APIs. You only have two
|
|
options:
|
|
|
|
1. Not call the affected API.
|
|
2. Not run your code on .NET Framework 4.6.1.
|
|
|
|
## When to suppress warnings
|
|
|
|
Unless you stop calling the API entirely, you have to suppress this warning as shown in the following example:
|
|
|
|
```C#
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
[assembly: SuppressMessage("Usage", "PC002:API not available in .NET Framework 4.6.1", Justification = "This library will not run on .NET Framework 4.6.1")]
|
|
```
|
|
|
|
[netfx-netstandard]: https://github.com/dotnet/standard/blob/master/docs/netstandard-20/README.md#net-framework-461-supporting-net-standard-20
|