Add netcoreapp build of System.Formats.Asn1
authorJeremy Barton <jbarton@microsoft.com>
Wed, 26 Aug 2020 16:27:01 +0000 (09:27 -0700)
committerGitHub <noreply@github.com>
Wed, 26 Aug 2020 16:27:01 +0000 (09:27 -0700)
This avoids the library causing a cyclic dependency in generating netstandard.dll.
The netcoreapp version is not included in the NuGet package,
following the pattern of
  * System.Text.Json
  * System.Collections.Immutable
  * System.Reflection.Metadata

src/libraries/System.Formats.Asn1/src/System.Formats.Asn1.csproj
src/libraries/System.Formats.Asn1/src/System/Formats/Asn1/AsnWriter.cs

index f9fdc8c..999a3c5 100644 (file)
@@ -2,7 +2,8 @@
   <PropertyGroup>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <Nullable>enable</Nullable>
-    <TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
+    <TargetFrameworks>$(NetCoreAppCurrent);netstandard2.0;net461</TargetFrameworks>
+    <ExcludeCurrentNetCoreAppFromPackage>true</ExcludeCurrentNetCoreAppFromPackage>
   </PropertyGroup>
   <ItemGroup>
     <Compile Include="$(CommonPath)System\Security\Cryptography\CryptoPool.cs">
     <Compile Include="System\Formats\Asn1\TagClass.cs" />
     <Compile Include="System\Formats\Asn1\UniversalTagNumber.cs" />
   </ItemGroup>
-  <ItemGroup>
-    <PackageReference Include="System.Buffers" Version="$(SystemBuffersVersion)" />
-    <PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
-  </ItemGroup>
+  <Choose>
+    <When Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'">
+      <ItemGroup>
+        <Reference Include="System.Buffers" />
+        <Reference Include="System.Collections" />
+        <Reference Include="System.Memory" />
+        <Reference Include="System.Runtime" />
+        <Reference Include="System.Runtime.InteropServices" />
+        <Reference Include="System.Runtime.Numerics" />
+        <Reference Include="System.Security.Cryptography.Primitives" />
+        <Reference Include="System.Text.Encoding.Extensions" />
+      </ItemGroup>
+    </When>
+    <Otherwise>
+      <ItemGroup>
+        <PackageReference Include="System.Buffers" Version="$(SystemBuffersVersion)" />
+        <PackageReference Include="System.Memory" Version="$(SystemMemoryVersion)" />
+      </ItemGroup>
+    </Otherwise>
+  </Choose>
   <ItemGroup Condition="$(TargetFramework.StartsWith('net4'))">
     <Reference Include="System.Numerics" />
     <PackageReference Include="System.ValueTuple" Version="$(SystemValueTupleVersion)" Condition="'$(TargetFramework)' == 'net461'" />
index fbdb8e7..c5e10fd 100644 (file)
@@ -730,7 +730,9 @@ namespace System.Formats.Asn1
 
             public void Dispose()
             {
-                if (_writer == null || _writer._nestingStack.Count == 0)
+                Debug.Assert(_writer == null || _writer._nestingStack != null);
+
+                if (_writer == null || _writer._nestingStack!.Count == 0)
                 {
                     return;
                 }