.NET Standard / .NET Core Code Analysis and Code Contracts with VS 2017

Are static code analysis and code contracts supported for .NET Standard ?

VS 2017 and .NET Standard 1.6 or the .NET classes of the base class do not seem to have parameters for performing code analysis.

+4
source share
1 answer

You can use Code Contracts for standard .NET projects (I have); however, there is no support for VS ID ID 2017 for the inclusion of code contracts in any project, not to mention the netstandard project.

(ccrewrite) , PDB. , netstandard PDB ( PDB, ).

. netstandard, /Windows PDB . / Windows PDB netstandard- , , , .

VS Code , , Code Contracts VS 2017 builds. , PDB. csproj msbuild :

  <!-- For netstandard and netcoreapp, DebugType must be full or pdbonly for ccrewrite to work -->
  <PropertyGroup Condition=" '$(Configuration)' != 'Release' ">
    <DebugType>full</DebugType>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
    <CodeContractsRuntimeCheckingLevel>ReleaseRequires</CodeContractsRuntimeCheckingLevel>
    <DebugType>pdbonly</DebugType>
  </PropertyGroup>
+1

Source: https://habr.com/ru/post/1678311/


All Articles