Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .NET 5 support #630

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion YamlDotNet.Test/Core/EmitterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public void UnicodeInScalarsCanBeSingleQuotedWhenOutputEncodingSupportsIt(string
)
);
var buffer = new MemoryStream();
#if (NETCOREAPP2_1 || NETCOREAPP3_1)
#if NETCOREAPP3_1_OR_GREATER
// Code pages such as Cyrillic are not recognized by default in
// .NET Core. We need to register this provider.
// https://msdn.microsoft.com/en-us/library/mt643899(v=vs.110).aspx#Remarks
Expand Down
2 changes: 1 addition & 1 deletion YamlDotNet.Test/YamlDotNet.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net46;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>net46;netcoreapp3.1;net5</TargetFrameworks>
<IsPackable>false</IsPackable>
<AssemblyOriginatorKeyFile>..\YamlDotNet.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand Down
20 changes: 10 additions & 10 deletions YamlDotNet/Helpers/OrderedDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ public void RemoveAt(int index)
list.RemoveAt(index);
}

#if !(NETCOREAPP3_1)
#if !NETCOREAPP3_1_OR_GREATER
#pragma warning disable 8767 // Nullability of reference types in type of parameter ... doesn't match implicitly implemented member
#endif

public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) =>
dictionary.TryGetValue(key, out value);

#if !(NETCOREAPP3_1)
#if !NETCOREAPP3_1_OR_GREATER
#pragma warning restore 8767
#endif

Expand Down Expand Up @@ -182,10 +182,10 @@ public KeyCollection(OrderedDictionary<TKey, TValue> orderedDictionary)

public void CopyTo(TKey[] array, int arrayIndex)
{
for (var i = 0; i < orderedDictionary.list.Count; i++)
{
array[i] = orderedDictionary.list[i + arrayIndex].Key;
}
for (var i = 0; i < orderedDictionary.list.Count; i++)
{
array[i] = orderedDictionary.list[i + arrayIndex].Key;
}
}

public IEnumerator<TKey> GetEnumerator() =>
Expand Down Expand Up @@ -217,10 +217,10 @@ public ValueCollection(OrderedDictionary<TKey, TValue> orderedDictionary)

public void CopyTo(TValue[] array, int arrayIndex)
{
for (var i = 0; i < orderedDictionary.list.Count; i++)
{
array[i] = orderedDictionary.list[i + arrayIndex].Value;
}
for (var i = 0; i < orderedDictionary.list.Count; i++)
{
array[i] = orderedDictionary.list[i + arrayIndex].Value;
}
}

public IEnumerator<TValue> GetEnumerator() =>
Expand Down
4 changes: 2 additions & 2 deletions YamlDotNet/Serialization/Utilities/TypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
// used in YamlDotNet.

using System;
using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using System.ComponentModel;

namespace YamlDotNet.Serialization.Utilities
{
Expand Down Expand Up @@ -247,7 +247,7 @@ partial class TypeConverter
/// </summary>
/// <typeparam name="TConvertible">The type to which the converter should be associated.</typeparam>
/// <typeparam name="TConverter">The type of the converter.</typeparam>
#if !(NETCOREAPP3_1 || NETSTANDARD2_1 || NETSTANDARD1_3 || UNITY)
#if !(NETCOREAPP3_1_OR_GREATER || NETSTANDARD2_1 || NETSTANDARD1_3 || UNITY)
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.LinkDemand, Name = "FullTrust")]
#endif
public static void RegisterTypeConverter<TConvertible, TConverter>()
Expand Down
54 changes: 10 additions & 44 deletions YamlDotNet/YamlDotNet.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;netstandard2.1;netstandard1.3;net20;net35;net40;net45</TargetFrameworks>

<TargetFrameworks>net5;netcoreapp3.1;netstandard2.1;netstandard1.3;net20;net35;net40;net45</TargetFrameworks>
<PackageProjectUrl>https://github.com/aaubry/YamlDotNet</PackageProjectUrl>
<RepositoryUrl>https://github.com/aaubry/YamlDotNet</RepositoryUrl>
<Description>YamlDotNet is a .NET library for YAML. YamlDotNet provides low level parsing and emitting of YAML as well as a high level object model similar to XmlDocument. A serialization library is also included that allows to read and write objects from and to YAML streams.</Description>
Expand All @@ -19,7 +18,6 @@
<LangVersion>8.0</LangVersion>
<Nullable>enable</Nullable>

<NetStandard>false</NetStandard>
<RealTargetFramework>$(TargetFramework)</RealTargetFramework>
</PropertyGroup>

Expand All @@ -32,10 +30,6 @@
<NoWarn>1591;1574;8600;8602;8604</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.3' Or '$(TargetFramework)' == 'netstandard2.1' Or '$(TargetFramework)' == 'netcoreapp3.1'">
<NetStandard>true</NetStandard>
</PropertyGroup>

<ItemGroup>
<None Include="Helpers/Portability/**/*.cs" />
<Compile Remove="Helpers/Portability/**/*.cs" />
Expand All @@ -48,30 +42,6 @@
<PackageReference Include="Nullable" Version="1.1.1" PrivateAssets="all" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ComponentModel.TypeConverter">
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.3'">
<PackageReference Include="System.ComponentModel.TypeConverter">
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="System.ComponentModel.TypeConverter">
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="System.ComponentModel.TypeConverter">
<Version>4.3.0</Version>
</PackageReference>
</ItemGroup>

<Import Project="../build/common.props" />

<PropertyGroup Condition="'$(RealTargetFramework)' == 'unitysubset3.5'">
Expand All @@ -90,28 +60,24 @@
Remove implicit framework references, to prevent warning of missing System.Drawing
when targetting Unity.
-->
<PropertyGroup Condition="'$(NetStandard)' == 'false'">
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp3.1|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup Condition="'$(NetStandard)' == 'false'">
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<Reference Include="System" />
</ItemGroup>
<ItemGroup Condition="'$(NetStandard)' == 'false' And '$(TargetFramework)' != 'net20'">
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' And '$(TargetFramework)' != 'net20'">
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup Condition="'$(NetStandard)' == 'true'">
<PackageReference Include="System.Runtime.Serialization.Formatters">
<Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.ComponentModel.TypeConverter">
<Version>4.3.0</Version>
</PackageReference>
<PackageReference Include="System.Diagnostics.Debug">
<Version>4.3.0</Version>
</PackageReference>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework' or '$(TargetFramework)' == 'net45'">
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework'">
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
</ItemGroup>

<Target Name="Info" BeforeTargets="CoreCompile">
Expand Down