<PropertyGroup>
<AssemblyVersion>4.0.5.0</AssemblyVersion>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
+ <IsNETCoreApp>true</IsNETCoreApp>
<IsUAP>true</IsUAP>
</PropertyGroup>
</Project>
<!-- this package is part of the implementation closure of NETStandard.Library
therefore it cannot reference NETStandard.Library -->
<SuppressMetaPackage Include="NETStandard.Library" />
- <InboxOnTargetFramework Include="uap10.0.16300" />
+
+ <!-- Since UAP and .NETCoreApp are package based we still want to enable
+ OOBing libraries that happen to overlap with their framework package.
+ This avoids us having to lock the API in our NuGet packages just
+ to match what shipped inbox: since we can provide a new library
+ we can update it to add API without raising the netstandard version. -->
+ <ValidatePackageSuppression Include="TreatAsOutOfBox">
+ <Value>.NETCoreApp;UAP</Value>
+ </ValidatePackageSuppression>
</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), Directory.Build.targets))\Directory.Build.targets" />
</Project>
\ No newline at end of file
<Reference Include="System.Memory" />
<Reference Include="System.Resources.ResourceManager" />
<Reference Include="System.Runtime" />
+ <Reference Include="System.Runtime.CompilerServices.Unsafe" />
<Reference Include="System.Runtime.Extensions" />
<Reference Include="System.Text.Encoding.Extensions" />
<Reference Include="System.Threading" />
using System.Diagnostics;
using System.Globalization;
using System.IO;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
// which just returns the value of its sole Int64 dateData field. Here, we don't
// have access to that member (which doesn't even exist anymore, since it was only for
// BinaryFormatter, which is now in a separate assembly). To address that,
- // we access the sole field directly via an unsafe cast; ideally this would
- // just use Unsafe.As, but since we can't use that here due to not having a netcoreapp
- // build of System.Runtime.CompilerServices.Unsafe.dll, we instead go through span.
- long dateData = MemoryMarshal.Cast<DateTime, long>(MemoryMarshal.CreateReadOnlySpan(ref value, 1))[0];
+ // we access the sole field directly via an unsafe cast.
+ long dateData = Unsafe.As<DateTime, long>(ref value);
WriteInt64(dateData);
}
[CLSCompliant(false)]
public static bool TryCreate(uint value, out Rune result) { throw null; }
public bool TryEncode(Span<char> destination, out int charsWritten) { throw null; }
+ public bool TryEncodeToUtf8Bytes(Span<byte> destination, out int bytesWritten) { throw null; }
public static bool TryGetRuneAt(string input, int index, out Rune value) { throw null; }
public static double GetNumericValue(Rune value) { throw null; }
public static System.Globalization.UnicodeCategory GetUnicodeCategory(Rune value) { throw null; }
// First, try with a buffer that's too short
Span<byte> utf8Buffer = stackalloc byte[rune.Utf8SequenceLength - 1];
- bool success = TryEncodeToUtf8Bytes_Fn(ref rune, utf8Buffer, out int bytesWritten);
+ bool success = rune.TryEncodeToUtf8Bytes(utf8Buffer, out int bytesWritten);
Assert.False(success);
Assert.Equal(0, bytesWritten);
// Then, try with a buffer that's appropriately sized
utf8Buffer = stackalloc byte[rune.Utf8SequenceLength];
- success = TryEncodeToUtf8Bytes_Fn(ref rune, utf8Buffer, out bytesWritten);
+ success = rune.TryEncodeToUtf8Bytes(utf8Buffer, out bytesWritten);
Assert.True(success);
Assert.Equal(testData.Utf8Sequence.Length, bytesWritten);
Assert.True(utf8Buffer.SequenceEqual(testData.Utf8Sequence));
// Finally, try with a buffer that's too long (should succeed)
utf8Buffer = stackalloc byte[rune.Utf8SequenceLength + 1];
- success = TryEncodeToUtf8Bytes_Fn(ref rune, utf8Buffer, out bytesWritten);
+ success = rune.TryEncodeToUtf8Bytes(utf8Buffer, out bytesWritten);
Assert.True(success);
Assert.Equal(testData.Utf8Sequence.Length, bytesWritten);
Assert.True(utf8Buffer.Slice(0, testData.Utf8Sequence.Length).SequenceEqual(testData.Utf8Sequence));
}
-
- private delegate bool TryEncodeToUtf8Bytes_Del(ref Rune rune, Span<byte> destination, out int bytesWritten);
- private static readonly TryEncodeToUtf8Bytes_Del TryEncodeToUtf8Bytes_Fn = CreateTryEncodeToUtf8BytesDelegate();
-
- private static TryEncodeToUtf8Bytes_Del CreateTryEncodeToUtf8BytesDelegate()
- {
- var methodInfo = typeof(Rune).GetMethod("TryEncodeToUtf8Bytes", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
- return (TryEncodeToUtf8Bytes_Del)methodInfo.CreateDelegate(typeof(TryEncodeToUtf8Bytes_Del));
- }
}
}
<!-- For the inbox library (that is shipping with the product), this should always be true. -->
<!-- BUILDING_INBOX_LIBRARY is only false when building for netstandard to validate that the sources are netstandard compatible. -->
<!-- This is meant to help with producing a source package and not to ship a netstandard compatible binary. -->
- <DefineConstants Condition="'$(TargetGroup)' != 'netstandard'">$(DefineConstants);BUILDING_INBOX_LIBRARY</DefineConstants>
+ <DefineConstants Condition="'$(TargetsNETStandard)' != 'true'">$(DefineConstants);BUILDING_INBOX_LIBRARY</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="System\Text\Json\BitStack.cs" />
<Compile Include="System\Text\Json\Writer\Utf8JsonWriter.WriteValues.String.cs" />
<Compile Include="System\Text\Json\Writer\Utf8JsonWriter.WriteValues.UnsignedNumber.cs" />
</ItemGroup>
- <ItemGroup Condition="'$(TargetGroup)' != 'netstandard'">
- <ProjectReference Include="..\..\System.Memory\src\System.Memory.csproj" />
- <ProjectReference Include="..\..\System.Runtime.Extensions\src\System.Runtime.Extensions.csproj" />
+ <ItemGroup Condition="'$(TargetsNETStandard)' != 'true'">
+ <Reference Include="System.Diagnostics.Debug" />
+ <Reference Include="System.Resources.ResourceManager" />
+ <Reference Include="System.Runtime" />
+ <Reference Include="System.Runtime.Extensions" />
+ <Reference Include="System.Text.Encoding.Extensions" />
+ <Reference Include="System.Threading.Tasks" />
</ItemGroup>
- <ItemGroup Condition="'$(TargetGroup)' != 'netstandard'">
- <ReferenceFromRuntime Include="System.Private.CoreLib" />
- </ItemGroup>
- <ItemGroup Condition="'$(TargetGroup)' == 'netstandard'">
+ <ItemGroup>
<Reference Include="System.Buffers" />
<Reference Include="System.Memory" />
<Reference Include="System.Numerics.Vectors" />
using System.Buffers.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
-#if BUILDING_INBOX_LIBRARY
-using Internal.Runtime.CompilerServices;
-#else
using System.Runtime.CompilerServices;
-#endif
namespace System.Text.Json
{
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-#if BUILDING_INBOX_LIBRARY
-using Internal.Runtime.CompilerServices;
-#endif
-
namespace System.Text.Json
{
internal static partial class JsonReaderHelper
],
"BaselineVersion": "4.5.1",
"InboxOn": {
- "uap10.0.16300": "4.0.5.0"
+ "uap10.0.16300": "4.0.5.0",
+ "netcoreapp3.0": "4.0.5.0"
},
"AssemblyVersionInPackageVersion": {
"4.0.3.0": "4.4.0",
<!-- use the most recent MS.NETCore.App we have from upstack -->
<RuntimeFrameworkVersion>$(MicrosoftNETCoreAppPackageVersion)</RuntimeFrameworkVersion>
</PropertyGroup>
+ <ItemGroup>
+ <!-- unsafe is part of the framework but we don't yet have a MicrosoftNETCoreAppPackageVersion with that change -->
+ <IgnoredReference Include="System.Runtime.CompilerServices.Unsafe"/>
+ </ItemGroup>
+ <Target Name="CheckForWorkaroundRemoval" AfterTargets="ResolveReferences">
+ <Error Condition="'%(Reference.FileName)' == 'System.Runtime.CompilerServices.Unsafe' AND '%(Reference.NuGetPackageId)' == 'Microsoft.NETCore.App'"
+ Text="Please remove IgnoredReference workaround from pkg\test\frameworkSettings\netcoreapp3.0\settings.targets" />
+ </Target>
</Project>