From ab695ac3311a056318f91f26154cfc609f963a89 Mon Sep 17 00:00:00 2001 From: Edward Cooke Date: Mon, 22 Jan 2024 10:35:44 -0700 Subject: [PATCH 1/3] Removed old frameworks --- BuildUtils.UnityPrerequisites | 1 - CONTRIBUTING.md | 2 +- Dockerfile | 5 +- Dockerfile.NonEnglish | 7 +- README.md | 8 - YamlDotNet.AotTest/App.config | 6 - YamlDotNet.AotTest/Program.cs | 130 ------------- YamlDotNet.AotTest/YamlDotNet.AotTest.csproj | 34 ---- YamlDotNet.AotTest/run.sh | 7 - ...amlDotNet.Core7AoTCompileTest.Model.csproj | 2 - .../YamlDotNet.Core7AoTCompileTest.csproj | 2 - YamlDotNet.Test/YamlDotNet.Test.csproj | 2 - YamlDotNet.sln | 12 +- .../include => }/CultureInfoAdapter.cs | 8 +- .../ReadOnlyCollectionExtensions.cs | 0 .../include/DeconstructionExtensions.cs | 32 ---- .../include/ConcurrentDictionary.cs | 67 ------- .../include/IReadOnlyCollection.cs | 28 --- .../include/IReadOnlyDictionary.cs | 34 ---- .../include/IReadOnlyList.cs | 28 --- .../net35+unitysubset3.5/include/Lazy.cs | 95 ---------- .../net35+unitysubset3.5/include/Linq.cs | 38 ---- .../include/ReadOnlyCollectionExtensions.cs | 83 --------- .../include/ValueTuple.cs | 50 ----- .../net45+net47/include/LazyBuilder.cs | 35 ---- .../exclude/CultureInfoAdapter.cs | 42 ----- .../exclude/ReflectionExtensions.cs | 174 ------------------ .../ExcludeFromCodeCoverageAttribute.cs | 31 ---- .../include/PropertyInfoExtensions.cs | 33 ---- .../include/StandardRegexOptions.cs | 30 --- .../include/TargetFrameworkAttribute.cs | 38 ---- .../exclude => }/PropertyInfoExtensions.cs | 0 .../include => }/ReflectionExtensions.cs | 7 +- .../TypeAssigningEventEmitter.cs | 1 + .../Serialization/Utilities/TypeConverter.cs | 4 +- .../exclude => }/StandardRegexOptions.cs | 0 YamlDotNet/YamlDotNet.csproj | 33 +--- build/common.props | 5 - tools/aot/Dockerfile | 10 - tools/aot/build.ps1 | 2 - tools/build/BuildDefinition.cs | 24 +-- 41 files changed, 19 insertions(+), 1131 deletions(-) delete mode 160000 BuildUtils.UnityPrerequisites delete mode 100644 YamlDotNet.AotTest/App.config delete mode 100644 YamlDotNet.AotTest/Program.cs delete mode 100644 YamlDotNet.AotTest/YamlDotNet.AotTest.csproj delete mode 100755 YamlDotNet.AotTest/run.sh rename YamlDotNet/{Portability/netstandard2.0+netstandard2.1/include => }/CultureInfoAdapter.cs (87%) rename YamlDotNet/{Portability/net35+unitysubset3.5/exclude => Helpers}/ReadOnlyCollectionExtensions.cs (100%) delete mode 100644 YamlDotNet/Portability/net35+unitysubset3.5+net45+net47/include/DeconstructionExtensions.cs delete mode 100644 YamlDotNet/Portability/net35+unitysubset3.5/include/ConcurrentDictionary.cs delete mode 100644 YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyCollection.cs delete mode 100644 YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyDictionary.cs delete mode 100644 YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyList.cs delete mode 100644 YamlDotNet/Portability/net35+unitysubset3.5/include/Lazy.cs delete mode 100644 YamlDotNet/Portability/net35+unitysubset3.5/include/Linq.cs delete mode 100644 YamlDotNet/Portability/net35+unitysubset3.5/include/ReadOnlyCollectionExtensions.cs delete mode 100644 YamlDotNet/Portability/net35+unitysubset3.5/include/ValueTuple.cs delete mode 100644 YamlDotNet/Portability/net45+net47/include/LazyBuilder.cs delete mode 100644 YamlDotNet/Portability/netstandard2.0+netstandard2.1/exclude/CultureInfoAdapter.cs delete mode 100644 YamlDotNet/Portability/netstandard2.0+netstandard2.1/exclude/ReflectionExtensions.cs delete mode 100644 YamlDotNet/Portability/unitysubset3.5/include/ExcludeFromCodeCoverageAttribute.cs delete mode 100644 YamlDotNet/Portability/unitysubset3.5/include/PropertyInfoExtensions.cs delete mode 100644 YamlDotNet/Portability/unitysubset3.5/include/StandardRegexOptions.cs delete mode 100644 YamlDotNet/Portability/unitysubset3.5/include/TargetFrameworkAttribute.cs rename YamlDotNet/{Portability/unitysubset3.5/exclude => }/PropertyInfoExtensions.cs (100%) rename YamlDotNet/{Portability/netstandard2.0+netstandard2.1/include => }/ReflectionExtensions.cs (97%) rename YamlDotNet/{Portability/unitysubset3.5/exclude => }/StandardRegexOptions.cs (100%) delete mode 100644 build/common.props delete mode 100644 tools/aot/Dockerfile delete mode 100644 tools/aot/build.ps1 diff --git a/BuildUtils.UnityPrerequisites b/BuildUtils.UnityPrerequisites deleted file mode 160000 index 0db1240a0..000000000 --- a/BuildUtils.UnityPrerequisites +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0db1240a03a5bdf9f4666c3b0fc511cc4622104a diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a6231f10b..6618aa8bc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -113,7 +113,7 @@ on the build variables. Some platforms - such as IOS - forbid dynamic code generation. This prevents Just-in-Time compilation (JIT) from being used. In those cases, one can use Mono's Ahead-of-Time compilation (AOT). This results on a precompiled assembly that does not rely on JIT. There are [some limitations](http://www.mono-project.com/docs/advanced/aot/#limitation-generic-interface-instantiation) however, most of them are related to usage of generics. -In order to ensure that YamlDotNet is compatible with AOT compilation, an automatic test has been created that runs on every commit. That test exercises the serializer and deserializer to help identify AOT-related problems. +You can use the StaticSerializerBuilder and StaticDeserializerBuilder to accomplish this. ## Coding style diff --git a/Dockerfile b/Dockerfile index 84465faee..af31659b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,6 +17,7 @@ RUN wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod RUN dpkg -i packages-microsoft-prod.deb RUN apt update RUN apt install -y dotnet-sdk-6.0 +RUN apt install -y dotnet-sdk-7.0 FROM builder AS build WORKDIR /src @@ -24,7 +25,6 @@ ARG PACKAGE_VERSION=1.0.0 COPY YamlDotNet.sln YamlDotNet.sln COPY YamlDotNet/YamlDotNet.csproj YamlDotNet/YamlDotNet.csproj -COPY YamlDotNet.AotTest/YamlDotNet.AotTest.csproj YamlDotNet.AotTest/YamlDotNet.AotTest.csproj COPY YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj COPY YamlDotNet.Samples/YamlDotNet.Samples.csproj YamlDotNet.Samples/YamlDotNet.Samples.csproj COPY YamlDotNet.Test/YamlDotNet.Test.csproj YamlDotNet.Test/YamlDotNet.Test.csproj @@ -37,9 +37,6 @@ RUN dotnet restore YamlDotNet.sln COPY . . -RUN dotnet build -c Release --framework net35 YamlDotNet/YamlDotNet.csproj -o /output/net35 -RUN dotnet build -c Release --framework net40 YamlDotNet/YamlDotNet.csproj -o /output/net40 -RUN dotnet build -c Release --framework net45 YamlDotNet/YamlDotNet.csproj -o /output/net45 RUN dotnet build -c Release --framework net47 YamlDotNet/YamlDotNet.csproj -o /output/net47 RUN dotnet build -c Release --framework netstandard2.0 YamlDotNet/YamlDotNet.csproj -o /output/netstandard2.0 RUN dotnet build -c Release --framework netstandard2.1 YamlDotNet/YamlDotNet.csproj -o /output/netstandard2.1 diff --git a/Dockerfile.NonEnglish b/Dockerfile.NonEnglish index ed3b844ed..69c454a7e 100644 --- a/Dockerfile.NonEnglish +++ b/Dockerfile.NonEnglish @@ -18,6 +18,7 @@ RUN wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod RUN dpkg -i packages-microsoft-prod.deb RUN apt update RUN apt install -y dotnet-sdk-6.0 +RUN apt install -y dotnet-sdk-7.0 FROM builder AS build @@ -26,22 +27,18 @@ ARG PACKAGE_VERSION=1.0.0 COPY YamlDotNet.sln YamlDotNet.sln COPY YamlDotNet/YamlDotNet.csproj YamlDotNet/YamlDotNet.csproj -COPY YamlDotNet.AotTest/YamlDotNet.AotTest.csproj YamlDotNet.AotTest/YamlDotNet.AotTest.csproj COPY YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj YamlDotNet.Benchmark/YamlDotNet.Benchmark.csproj COPY YamlDotNet.Samples/YamlDotNet.Samples.csproj YamlDotNet.Samples/YamlDotNet.Samples.csproj COPY YamlDotNet.Test/YamlDotNet.Test.csproj YamlDotNet.Test/YamlDotNet.Test.csproj COPY YamlDotNet.Analyzers.StaticGenerator/YamlDotNet.Analyzers.StaticGenerator.csproj YamlDotNet.Analyzers.StaticGenerator/YamlDotNet.Analyzers.StaticGenerator.csproj COPY YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj COPY YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj -COPY YamlDotNet.Samples.Fsharp/YamlDotNet.Samples.Fsharp.csproj YamlDotNet.Samples.Fsharp/YamlDotNet.Samples.Fsharp.csproj +COPY YamlDotNet.Samples.Fsharp/YamlDotNet.Samples.Fsharp.fsproj YamlDotNet.Samples.Fsharp/YamlDotNet.Samples.Fsharp.fsproj RUN dotnet restore YamlDotNet.sln COPY . . -RUN dotnet build -c Release --framework net35 YamlDotNet/YamlDotNet.csproj -o /output/net35 -RUN dotnet build -c Release --framework net40 YamlDotNet/YamlDotNet.csproj -o /output/net40 -RUN dotnet build -c Release --framework net45 YamlDotNet/YamlDotNet.csproj -o /output/net45 RUN dotnet build -c Release --framework net47 YamlDotNet/YamlDotNet.csproj -o /output/net47 RUN dotnet build -c Release --framework netstandard2.0 YamlDotNet/YamlDotNet.csproj -o /output/netstandard2.0 RUN dotnet build -c Release --framework netstandard2.1 YamlDotNet/YamlDotNet.csproj -o /output/netstandard2.1 diff --git a/README.md b/README.md index 60b567a3f..71d916a07 100644 --- a/README.md +++ b/README.md @@ -30,14 +30,6 @@ The library has now been successfully used in multiple projects and is considere * .NET 6.0 * .NET 7.0 * .NET Framework 4.7 -* .NET Framework 4.5 -* Unity Subset v3.5 - -The following runtimes are also supported, with a few features missing: - -* .NET Framework 3.5 - -The library is compatible with mono's [Ahead-of-Time compilation](https://www.mono-project.com/docs/advanced/aot/) (AOT), and should work correctly on platforms that depend on it, such as Unity. ## Quick start diff --git a/YamlDotNet.AotTest/App.config b/YamlDotNet.AotTest/App.config deleted file mode 100644 index d3d299647..000000000 --- a/YamlDotNet.AotTest/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/YamlDotNet.AotTest/Program.cs b/YamlDotNet.AotTest/Program.cs deleted file mode 100644 index 4f47152aa..000000000 --- a/YamlDotNet.AotTest/Program.cs +++ /dev/null @@ -1,130 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Collections.Generic; -using System.IO; -using YamlDotNet.Serialization; -using YamlDotNet.Serialization.NamingConventions; -using YamlDotNet.Test.Serialization; - -namespace YamlDotNet.AotTest -{ - class Program - { - static int Main() - { - Console.WriteLine(); - Console.WriteLine("\x1b[37m---------------------------------------------------------------------------------"); - Console.WriteLine(); - - Console.WriteLine("\x1b[97m Running AOT tests..."); - Console.WriteLine(); - - TryDeserialize("DictionaryNodeDeserializer", "myDictionary: { winners: 3 }"); - TryDeserialize("CollectionNodeDeserializer", "myList: [ 1, 2, 3 ]"); - TryDeserialize("ArayNodeDeserializer", "myArray: [ 1, 2, 3 ]"); - TrySerialize("TraverseGenericDictionary", new GenericTestDictionary { { 1, 2 } }); - - Console.WriteLine(); - Console.WriteLine(" \x1b[93m{0}\x1b[97m test succeeded, \x1b[93m{1}\x1b[97m tests failed", SucceededTestCount, FailedTestCount); - - Console.WriteLine(); - Console.WriteLine("\x1b[37m---------------------------------------------------------------------------------"); - Console.WriteLine("\x1b[0m"); - - return FailedTestCount; - } - - private static int SucceededTestCount; - private static int FailedTestCount; - - private static void TrySerialize(string testName, T graph) - { - var output = new StringWriter(); - var serializer = new SerializerBuilder() - .WithNamingConvention(CamelCaseNamingConvention.Instance) - .Build(); - PerformTest(testName, () => serializer.Serialize(output, graph)); - } - - private static void TryDeserialize(string testName, string yaml) - { - var input = new StringReader(yaml); - var deserializer = new DeserializerBuilder() - .WithNamingConvention(CamelCaseNamingConvention.Instance) - .Build(); - PerformTest(testName, () => deserializer.Deserialize(input)); - } - - private static void PerformTest(string testName, Action act) - { - Console.Write("\x1b[37m "); - Console.Write(testName.PadRight(70)); - - try - { - act(); - Console.WriteLine("\x1b[92m[success]\x1b[37m"); - ++SucceededTestCount; - } - catch (Exception ex) - { - var current = ex; - while (current != null) - { -#pragma warning disable CS0618 // Type or member is obsolete - if (current is ExecutionEngineException) -#pragma warning restore CS0618 // Type or member is obsolete - { - Console.WriteLine("\x1b[91m[failure]"); - Console.Write("\x1b[93m "); - Console.WriteLine(current.Message); - Console.Write("\x1b[37m"); - ++FailedTestCount; - return; - } - - current = current.InnerException; - } - Console.Write("\x1b[91m"); - throw; - } - } - } - -#pragma warning disable IDE1006 // Naming Styles - public class MyDictionary - { - public Dictionary myDictionary { get; set; } - } - - public class MyList - { - public List myList { get; set; } - } - - public class MyArray - { - public int[] myArray { get; set; } - } -#pragma warning restore IDE1006 // Naming Styles -} diff --git a/YamlDotNet.AotTest/YamlDotNet.AotTest.csproj b/YamlDotNet.AotTest/YamlDotNet.AotTest.csproj deleted file mode 100644 index 10abb325c..000000000 --- a/YamlDotNet.AotTest/YamlDotNet.AotTest.csproj +++ /dev/null @@ -1,34 +0,0 @@ - - - - Exe - net60;net45 - - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - - - {bf32de1b-6276-4341-b212-f8862adbba7a} - YamlDotNet - - - - - - GenericTestDictionary.cs - - - - diff --git a/YamlDotNet.AotTest/run.sh b/YamlDotNet.AotTest/run.sh deleted file mode 100755 index e5aed9622..000000000 --- a/YamlDotNet.AotTest/run.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -mono --aot=full ./bin/Release/net45/YamlDotNet.dll && \ - mono --aot=full ./bin/Release/net45/YamlDotNet.AotTest.exe && \ - mono --full-aot ./bin/Release/net45/YamlDotNet.AotTest.exe - -echo $? > exitcode.txt diff --git a/YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj b/YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj index 2dfd6d2c9..32ee4a56e 100644 --- a/YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj +++ b/YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj @@ -6,6 +6,4 @@ enable - - diff --git a/YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj b/YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj index 5867c74bd..9d42ee9a6 100644 --- a/YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj +++ b/YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj @@ -8,8 +8,6 @@ enable - - AnyCPU true diff --git a/YamlDotNet.Test/YamlDotNet.Test.csproj b/YamlDotNet.Test/YamlDotNet.Test.csproj index edd4dffd9..1bb955e1b 100644 --- a/YamlDotNet.Test/YamlDotNet.Test.csproj +++ b/YamlDotNet.Test/YamlDotNet.Test.csproj @@ -8,8 +8,6 @@ true - - diff --git a/YamlDotNet.sln b/YamlDotNet.sln index 85ca39759..e7d7d763e 100644 --- a/YamlDotNet.sln +++ b/YamlDotNet.sln @@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YamlDotNet.Samples", "YamlD EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YamlDotNet.Test", "YamlDotNet.Test\YamlDotNet.Test.csproj", "{A9F67018-0240-4D16-A4EA-BCB780D0AF05}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YamlDotNet.AotTest", "YamlDotNet.AotTest\YamlDotNet.AotTest.csproj", "{DF989FD9-3A2C-4807-A5D3-A8E755CA6648}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EB11D2D9-6E3D-45BF-8BCD-A04BCB1F8020}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig @@ -27,11 +25,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YamlDotNet.Benchmark", "Yam EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YamlDotNet.Analyzers.StaticGenerator", "YamlDotNet.Analyzers.StaticGenerator\YamlDotNet.Analyzers.StaticGenerator.csproj", "{42DE4D20-AEF7-4235-9CB2-1ED0150B3D1B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YamlDotNet.Core7AoTCompileTest", "YamlDotNet.Core7AoTCompileTest\YamlDotNet.Core7AoTCompileTest.csproj", "{DEB5099E-D216-438B-86A7-03674F9185EF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YamlDotNet.Core7AoTCompileTest", "YamlDotNet.Core7AoTCompileTest\YamlDotNet.Core7AoTCompileTest.csproj", "{DEB5099E-D216-438B-86A7-03674F9185EF}" EndProject -Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "YamlDotNet.Samples.Fsharp", "YamlDotNet.Samples.Fsharp\YamlDotNet.Samples.Fsharp.fsproj", "{C047392D-6B20-47CD-9FE6-D0FA326FD262}" +Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "YamlDotNet.Samples.Fsharp", "YamlDotNet.Samples.Fsharp\YamlDotNet.Samples.Fsharp.fsproj", "{C047392D-6B20-47CD-9FE6-D0FA326FD262}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YamlDotNet.Core7AoTCompileTest.Model", "YamlDotNet.Core7AoTCompileTest.Model\YamlDotNet.Core7AoTCompileTest.Model.csproj", "{BFE15564-7C2C-47DA-8302-9BCB39B6864B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "YamlDotNet.Core7AoTCompileTest.Model", "YamlDotNet.Core7AoTCompileTest.Model\YamlDotNet.Core7AoTCompileTest.Model.csproj", "{BFE15564-7C2C-47DA-8302-9BCB39B6864B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -51,10 +49,6 @@ Global {A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Debug|Any CPU.Build.0 = Debug|Any CPU {A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Release|Any CPU.ActiveCfg = Release|Any CPU {A9F67018-0240-4D16-A4EA-BCB780D0AF05}.Release|Any CPU.Build.0 = Release|Any CPU - {DF989FD9-3A2C-4807-A5D3-A8E755CA6648}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DF989FD9-3A2C-4807-A5D3-A8E755CA6648}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DF989FD9-3A2C-4807-A5D3-A8E755CA6648}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DF989FD9-3A2C-4807-A5D3-A8E755CA6648}.Release|Any CPU.Build.0 = Release|Any CPU {52D1E5F3-8337-48FC-AED5-968B51C7DAEB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {52D1E5F3-8337-48FC-AED5-968B51C7DAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU {52D1E5F3-8337-48FC-AED5-968B51C7DAEB}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/YamlDotNet/Portability/netstandard2.0+netstandard2.1/include/CultureInfoAdapter.cs b/YamlDotNet/CultureInfoAdapter.cs similarity index 87% rename from YamlDotNet/Portability/netstandard2.0+netstandard2.1/include/CultureInfoAdapter.cs rename to YamlDotNet/CultureInfoAdapter.cs index f315d766e..1087dfcdd 100644 --- a/YamlDotNet/Portability/netstandard2.0+netstandard2.1/include/CultureInfoAdapter.cs +++ b/YamlDotNet/CultureInfoAdapter.cs @@ -34,9 +34,13 @@ public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) this.provider = provider; } - public override object GetFormat(Type formatType) +#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER + public override object GetFormat(Type? formatType) +#else + public override object? GetFormat(Type formatType) +#endif { - return provider.GetFormat(formatType); + return provider.GetFormat(formatType)!; } } } diff --git a/YamlDotNet/Portability/net35+unitysubset3.5/exclude/ReadOnlyCollectionExtensions.cs b/YamlDotNet/Helpers/ReadOnlyCollectionExtensions.cs similarity index 100% rename from YamlDotNet/Portability/net35+unitysubset3.5/exclude/ReadOnlyCollectionExtensions.cs rename to YamlDotNet/Helpers/ReadOnlyCollectionExtensions.cs diff --git a/YamlDotNet/Portability/net35+unitysubset3.5+net45+net47/include/DeconstructionExtensions.cs b/YamlDotNet/Portability/net35+unitysubset3.5+net45+net47/include/DeconstructionExtensions.cs deleted file mode 100644 index 734c41608..000000000 --- a/YamlDotNet/Portability/net35+unitysubset3.5+net45+net47/include/DeconstructionExtensions.cs +++ /dev/null @@ -1,32 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -namespace System.Collections.Generic -{ - internal static class DeconstructionExtensions - { - public static void Deconstruct(this KeyValuePair pair, out TKey key, out TValue value) - { - key = pair.Key; - value = pair.Value; - } - } -} diff --git a/YamlDotNet/Portability/net35+unitysubset3.5/include/ConcurrentDictionary.cs b/YamlDotNet/Portability/net35+unitysubset3.5/include/ConcurrentDictionary.cs deleted file mode 100644 index 81b51a179..000000000 --- a/YamlDotNet/Portability/net35+unitysubset3.5/include/ConcurrentDictionary.cs +++ /dev/null @@ -1,67 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -namespace System.Collections.Concurrent -{ - internal sealed class ConcurrentDictionary - { - private readonly Dictionary entries = new Dictionary(); - - public delegate TValue ValueFactory(TKey key); - - public TValue GetOrAdd(TKey key, ValueFactory valueFactory) - { - lock (entries) - { - if (!entries.TryGetValue(key, out var value)) - { - value = valueFactory(key); - entries.Add(key, value); - } - return value; - } - } - - public bool TryAdd(TKey key, TValue value) - { - lock (entries) - { - if (!entries.ContainsKey(key)) - { - entries.Add(key, value); - return true; - } - return false; - } - } - - public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) - { - lock (entries) - { - return entries.TryGetValue(key, out value); - } - } - } -} diff --git a/YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyCollection.cs b/YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyCollection.cs deleted file mode 100644 index d1c1475c0..000000000 --- a/YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyCollection.cs +++ /dev/null @@ -1,28 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -namespace System.Collections.Generic -{ - public interface IReadOnlyCollection : IEnumerable, IEnumerable - { - int Count { get; } - } -} diff --git a/YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyDictionary.cs b/YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyDictionary.cs deleted file mode 100644 index 31ea4594b..000000000 --- a/YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyDictionary.cs +++ /dev/null @@ -1,34 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Diagnostics.CodeAnalysis; - -namespace System.Collections.Generic -{ - public interface IReadOnlyDictionary : IEnumerable>, IEnumerable, IReadOnlyCollection> where TKey : notnull - { - TValue this[TKey key] { get; } - IEnumerable Keys { get; } - IEnumerable Values { get; } - bool ContainsKey(TKey key); - bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value); - } -} diff --git a/YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyList.cs b/YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyList.cs deleted file mode 100644 index 221908b39..000000000 --- a/YamlDotNet/Portability/net35+unitysubset3.5/include/IReadOnlyList.cs +++ /dev/null @@ -1,28 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -namespace System.Collections.Generic -{ - public interface IReadOnlyList : IEnumerable, IEnumerable, IReadOnlyCollection - { - T this[int index] { get; } - } -} diff --git a/YamlDotNet/Portability/net35+unitysubset3.5/include/Lazy.cs b/YamlDotNet/Portability/net35+unitysubset3.5/include/Lazy.cs deleted file mode 100644 index 038b60a9d..000000000 --- a/YamlDotNet/Portability/net35+unitysubset3.5/include/Lazy.cs +++ /dev/null @@ -1,95 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -namespace System -{ - internal sealed class Lazy - { - private enum ValueState - { - NotCreated, - Creating, - Created, - } - - private T value; - private Func? valueFactory; - private ValueState valueState; - private readonly bool isThreadSafe; - - public Lazy(T value) - { - this.value = value; - valueState = ValueState.Created; - } - - public Lazy(Func valueFactory) - { - this.valueFactory = valueFactory; - this.isThreadSafe = false; - valueState = ValueState.NotCreated; - value = default!; - } - - public Lazy(Func valueFactory, bool isThreadSafe) - { - this.valueFactory = valueFactory; - this.isThreadSafe = isThreadSafe; - valueState = ValueState.NotCreated; - value = default!; - } - - public T Value - { - get - { - if (isThreadSafe) - { - lock (this) - { - return ComputeValue(); - } - } - else - { - return ComputeValue(); - } - } - } - - private T ComputeValue() - { - switch (valueState) - { - case Lazy.ValueState.NotCreated: - valueState = ValueState.Creating; - value = valueFactory(); - valueState = ValueState.Created; - valueFactory = null; - break; - - case Lazy.ValueState.Creating: - throw new InvalidOperationException("ValueFactory attempted to access the Value property of this instance."); - } - return value; - } - } -} diff --git a/YamlDotNet/Portability/net35+unitysubset3.5/include/Linq.cs b/YamlDotNet/Portability/net35+unitysubset3.5/include/Linq.cs deleted file mode 100644 index 482f9ae3a..000000000 --- a/YamlDotNet/Portability/net35+unitysubset3.5/include/Linq.cs +++ /dev/null @@ -1,38 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Collections.Generic; - -namespace System.Linq -{ - internal static partial class Enumerable2 - { - public static IEnumerable Zip(this IEnumerable first, IEnumerable second, Func resultSelector) - { - using var firstEnumerator = first.GetEnumerator(); - using var secondEnumerator = second.GetEnumerator(); - while (firstEnumerator.MoveNext() && secondEnumerator.MoveNext()) - { - yield return resultSelector(firstEnumerator.Current, secondEnumerator.Current); - } - } - } -} diff --git a/YamlDotNet/Portability/net35+unitysubset3.5/include/ReadOnlyCollectionExtensions.cs b/YamlDotNet/Portability/net35+unitysubset3.5/include/ReadOnlyCollectionExtensions.cs deleted file mode 100644 index 787dd559f..000000000 --- a/YamlDotNet/Portability/net35+unitysubset3.5/include/ReadOnlyCollectionExtensions.cs +++ /dev/null @@ -1,83 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; - -namespace YamlDotNet.Helpers -{ - internal static class ReadOnlyCollectionExtensions - { - private sealed class ReadOnlyListAdapter : IReadOnlyList - { - private readonly List list; - - public ReadOnlyListAdapter(List list) - { - this.list = list ?? throw new ArgumentNullException(nameof(list)); - } - - public T this[int index] => list[index]; - public int Count => list.Count; - public IEnumerator GetEnumerator() => list.GetEnumerator(); - - IEnumerator IEnumerable.GetEnumerator() => list.GetEnumerator(); - } - - public static IReadOnlyList AsReadonlyList(this List list) - { - return new ReadOnlyListAdapter(list); - } - - private sealed class ReadOnlyDictionaryAdapter : IReadOnlyDictionary where TKey : notnull - { - private readonly Dictionary dictionary; - - public ReadOnlyDictionaryAdapter(Dictionary dictionary) - { - this.dictionary = dictionary ?? throw new ArgumentNullException(nameof(dictionary)); - } - - public TValue this[TKey key] => dictionary[key]; - - public IEnumerable Keys => dictionary.Keys; - - public IEnumerable Values => dictionary.Values; - - public int Count => dictionary.Count; - - public bool ContainsKey(TKey key) => dictionary.ContainsKey(key); - - public IEnumerator> GetEnumerator() => dictionary.GetEnumerator(); - - public bool TryGetValue(TKey key, [MaybeNullWhen(false)] out TValue value) => dictionary.TryGetValue(key, out value); - - IEnumerator IEnumerable.GetEnumerator() => dictionary.GetEnumerator(); - } - - public static IReadOnlyDictionary AsReadonlyDictionary(this Dictionary dictionary) where TKey : notnull - { - return new ReadOnlyDictionaryAdapter(dictionary); - } - } -} diff --git a/YamlDotNet/Portability/net35+unitysubset3.5/include/ValueTuple.cs b/YamlDotNet/Portability/net35+unitysubset3.5/include/ValueTuple.cs deleted file mode 100644 index 7a34c15b6..000000000 --- a/YamlDotNet/Portability/net35+unitysubset3.5/include/ValueTuple.cs +++ /dev/null @@ -1,50 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Collections.Generic; - -namespace System.Runtime.CompilerServices -{ - internal sealed class TupleElementNamesAttribute : Attribute - { - public TupleElementNamesAttribute(string?[] transformNames) - { - TransformNames = transformNames; - } - - public IList TransformNames { get; } - } -} - -namespace System -{ - public struct ValueTuple - { - public T1 Item1; - public T2 Item2; - - public ValueTuple(T1 item1, T2 item2) - { - this.Item1 = item1; - this.Item2 = item2; - } - } -} diff --git a/YamlDotNet/Portability/net45+net47/include/LazyBuilder.cs b/YamlDotNet/Portability/net45+net47/include/LazyBuilder.cs deleted file mode 100644 index 6234d00b1..000000000 --- a/YamlDotNet/Portability/net45+net47/include/LazyBuilder.cs +++ /dev/null @@ -1,35 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; - -namespace YamlDotNet.Helpers -{ - internal static class Lazy - { - public static Lazy FromValue(T value) - { - var lazy = new Lazy(() => value, isThreadSafe: false); - var _ = lazy.Value; // Force evaluation - return lazy; - } - } -} diff --git a/YamlDotNet/Portability/netstandard2.0+netstandard2.1/exclude/CultureInfoAdapter.cs b/YamlDotNet/Portability/netstandard2.0+netstandard2.1/exclude/CultureInfoAdapter.cs deleted file mode 100644 index 15018f56b..000000000 --- a/YamlDotNet/Portability/netstandard2.0+netstandard2.1/exclude/CultureInfoAdapter.cs +++ /dev/null @@ -1,42 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Globalization; - -namespace YamlDotNet -{ - internal sealed class CultureInfoAdapter : CultureInfo - { - private readonly IFormatProvider provider; - - public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider) - : base(baseCulture.LCID) - { - this.provider = provider; - } - - public override object? GetFormat(Type? formatType) - { - return provider.GetFormat(formatType); - } - } -} diff --git a/YamlDotNet/Portability/netstandard2.0+netstandard2.1/exclude/ReflectionExtensions.cs b/YamlDotNet/Portability/netstandard2.0+netstandard2.1/exclude/ReflectionExtensions.cs deleted file mode 100644 index c175f64c0..000000000 --- a/YamlDotNet/Portability/netstandard2.0+netstandard2.1/exclude/ReflectionExtensions.cs +++ /dev/null @@ -1,174 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -namespace YamlDotNet -{ - internal static class ReflectionExtensions - { - public static Type? BaseType(this Type type) - { - return type.BaseType; - } - - public static bool IsValueType(this Type type) - { - return type.IsValueType; - } - - public static bool IsGenericType(this Type type) - { - return type.IsGenericType; - } - - public static bool IsGenericTypeDefinition(this Type type) - { - return type.IsGenericTypeDefinition; - } - - public static bool IsInterface(this Type type) - { - return type.IsInterface; - } - - public static bool IsEnum(this Type type) - { - return type.IsEnum; - } - - public static bool IsDbNull(this object value) - { - return value is DBNull; - } - - /// - /// Determines whether the specified type has a default constructor. - /// - /// The type. - /// Whether to include private constructors - /// - /// true if the type has a default constructor; otherwise, false. - /// - public static bool HasDefaultConstructor(this Type type, bool allowPrivateConstructors) - { - var bindingFlags = BindingFlags.Instance | BindingFlags.Public; - - if (allowPrivateConstructors) - { - bindingFlags |= BindingFlags.NonPublic; - } - - return type.IsValueType || type.GetConstructor(bindingFlags, null, Type.EmptyTypes, null) != null; - } - - public static TypeCode GetTypeCode(this Type type) - { - return Type.GetTypeCode(type); - } - - public static PropertyInfo? GetPublicProperty(this Type type, string name) - { - return type.GetProperty(name); - } - - public static FieldInfo? GetPublicStaticField(this Type type, string name) - { - return type.GetField(name, BindingFlags.Static | BindingFlags.Public); - } - - public static IEnumerable GetProperties(this Type type, bool includeNonPublic) - { - var bindingFlags = BindingFlags.Instance | BindingFlags.Public; - - if (includeNonPublic) - { - bindingFlags |= BindingFlags.NonPublic; - } - - return type.IsInterface - ? (new Type[] { type }) - .Concat(type.GetInterfaces()) - .SelectMany(i => i.GetProperties(bindingFlags)) - : type.GetProperties(bindingFlags); - } - - public static IEnumerable GetPublicProperties(this Type type) => GetProperties(type, false); - - public static IEnumerable GetPublicFields(this Type type) - { - return type.GetFields(BindingFlags.Instance | BindingFlags.Public); - } - - public static IEnumerable GetPublicStaticMethods(this Type type) - { - return type.GetMethods(BindingFlags.Static | BindingFlags.Public); - } - - public static MethodInfo GetPrivateStaticMethod(this Type type, string name) - { - return type.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic) - ?? throw new MissingMethodException($"Expected to find a method named '{name}' in '{type.FullName}'."); - } - - public static MethodInfo? GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes) - { - return type.GetMethod(name, BindingFlags.Public | BindingFlags.Static, null, parameterTypes, null); - } - - public static MethodInfo? GetPublicInstanceMethod(this Type type, string name) - { - return type.GetMethod(name, BindingFlags.Public | BindingFlags.Instance); - } - - private static readonly FieldInfo? RemoteStackTraceField = typeof(Exception) - .GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic); - - public static Exception Unwrap(this TargetInvocationException ex) - { - var result = ex.InnerException; - if (result == null) - { - return ex; - } - - if (RemoteStackTraceField != null) - { - RemoteStackTraceField.SetValue(result, result.StackTrace + "\r\n"); - } - return result; - } - - public static bool IsInstanceOf(this Type type, object o) - { - return type.IsInstanceOfType(o); - } - - public static Attribute[] GetAllCustomAttributes(this PropertyInfo property) - { - // Don't use IMemberInfo.GetCustomAttributes, it ignores the inherit parameter - return Attribute.GetCustomAttributes(property, typeof(TAttribute), true); - } - } -} diff --git a/YamlDotNet/Portability/unitysubset3.5/include/ExcludeFromCodeCoverageAttribute.cs b/YamlDotNet/Portability/unitysubset3.5/include/ExcludeFromCodeCoverageAttribute.cs deleted file mode 100644 index d3b208716..000000000 --- a/YamlDotNet/Portability/unitysubset3.5/include/ExcludeFromCodeCoverageAttribute.cs +++ /dev/null @@ -1,31 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Collections.Generic; -using System.Text; - -namespace System.Diagnostics.CodeAnalysis -{ - public sealed class ExcludeFromCodeCoverageAttribute : Attribute - { - } -} diff --git a/YamlDotNet/Portability/unitysubset3.5/include/PropertyInfoExtensions.cs b/YamlDotNet/Portability/unitysubset3.5/include/PropertyInfoExtensions.cs deleted file mode 100644 index eefd1381f..000000000 --- a/YamlDotNet/Portability/unitysubset3.5/include/PropertyInfoExtensions.cs +++ /dev/null @@ -1,33 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Reflection; - -namespace YamlDotNet -{ - internal static class PropertyInfoExtensions - { - public static object? ReadValue(this PropertyInfo property, object target) - { - return property.GetGetMethod().Invoke(target, null); - } - } -} diff --git a/YamlDotNet/Portability/unitysubset3.5/include/StandardRegexOptions.cs b/YamlDotNet/Portability/unitysubset3.5/include/StandardRegexOptions.cs deleted file mode 100644 index da727680c..000000000 --- a/YamlDotNet/Portability/unitysubset3.5/include/StandardRegexOptions.cs +++ /dev/null @@ -1,30 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System.Text.RegularExpressions; - -namespace YamlDotNet -{ - internal static class StandardRegexOptions - { - public const RegexOptions Compiled = RegexOptions.None; - } -} diff --git a/YamlDotNet/Portability/unitysubset3.5/include/TargetFrameworkAttribute.cs b/YamlDotNet/Portability/unitysubset3.5/include/TargetFrameworkAttribute.cs deleted file mode 100644 index a9b6d4919..000000000 --- a/YamlDotNet/Portability/unitysubset3.5/include/TargetFrameworkAttribute.cs +++ /dev/null @@ -1,38 +0,0 @@ -// This file is part of YamlDotNet - A .NET library for YAML. -// Copyright (c) Antoine Aubry and contributors -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do -// so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -namespace System.Runtime.Versioning -{ - // Unity uses the net40 target, because that simplifies the project configuration. - // But in practice it targets framework 3.5, which does not have the TargetFrameworkAttribute - // that is added to the generated AssemblyInfo. - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] - internal sealed class TargetFrameworkAttribute : Attribute - { - public string FrameworkName { get; set; } - public string? FrameworkDisplayName { get; set; } - - public TargetFrameworkAttribute(string frameworkName) - { - FrameworkName = frameworkName; - } - } -} diff --git a/YamlDotNet/Portability/unitysubset3.5/exclude/PropertyInfoExtensions.cs b/YamlDotNet/PropertyInfoExtensions.cs similarity index 100% rename from YamlDotNet/Portability/unitysubset3.5/exclude/PropertyInfoExtensions.cs rename to YamlDotNet/PropertyInfoExtensions.cs diff --git a/YamlDotNet/Portability/netstandard2.0+netstandard2.1/include/ReflectionExtensions.cs b/YamlDotNet/ReflectionExtensions.cs similarity index 97% rename from YamlDotNet/Portability/netstandard2.0+netstandard2.1/include/ReflectionExtensions.cs rename to YamlDotNet/ReflectionExtensions.cs index 476aa84f4..ebafdc488 100644 --- a/YamlDotNet/Portability/netstandard2.0+netstandard2.1/include/ReflectionExtensions.cs +++ b/YamlDotNet/ReflectionExtensions.cs @@ -243,7 +243,7 @@ public static MethodInfo GetPrivateStaticMethod(this Type type, string name) return getter; } - public static MethodInfo GetSetMethod(this PropertyInfo property) + public static MethodInfo? GetSetMethod(this PropertyInfo property) { return property.SetMethod; } @@ -253,11 +253,6 @@ public static IEnumerable GetInterfaces(this Type type) return type.GetTypeInfo().ImplementedInterfaces; } - public static Exception Unwrap(this TargetInvocationException ex) - { - return ex.InnerException; - } - public static bool IsInstanceOf(this Type type, object o) { return o.GetType() == type || o.GetType().GetTypeInfo().IsSubclassOf(type); diff --git a/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs b/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs index a2dfcb880..c81da5f3e 100644 --- a/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs +++ b/YamlDotNet/Serialization/EventEmitters/TypeAssigningEventEmitter.cs @@ -82,6 +82,7 @@ public TypeAssigningEventEmitter(IEventEmitter nextEmitter, INamingConvention enumNamingConvention) : base(nextEmitter) { + this.requireTagWhenStaticAndActualTypesAreDifferent = requireTagWhenStaticAndActualTypesAreDifferent; this.defaultScalarStyle = defaultScalarStyle; this.formatter = formatter; this.tagMappings = tagMappings; diff --git a/YamlDotNet/Serialization/Utilities/TypeConverter.cs b/YamlDotNet/Serialization/Utilities/TypeConverter.cs index f6272fa82..7bd79065c 100644 --- a/YamlDotNet/Serialization/Utilities/TypeConverter.cs +++ b/YamlDotNet/Serialization/Utilities/TypeConverter.cs @@ -203,7 +203,7 @@ public static T ChangeType(object? value, CultureInfo culture, INamingConvent } catch (TargetInvocationException ex) { - throw ex.Unwrap(); + throw ex.InnerException!; } } } @@ -231,7 +231,7 @@ public static T ChangeType(object? value, CultureInfo culture, INamingConvent } catch (TargetInvocationException ex) { - throw ex.Unwrap(); + throw ex.InnerException!; } } diff --git a/YamlDotNet/Portability/unitysubset3.5/exclude/StandardRegexOptions.cs b/YamlDotNet/StandardRegexOptions.cs similarity index 100% rename from YamlDotNet/Portability/unitysubset3.5/exclude/StandardRegexOptions.cs rename to YamlDotNet/StandardRegexOptions.cs diff --git a/YamlDotNet/YamlDotNet.csproj b/YamlDotNet/YamlDotNet.csproj index 29d554c6f..482c5fb2b 100644 --- a/YamlDotNet/YamlDotNet.csproj +++ b/YamlDotNet/YamlDotNet.csproj @@ -1,7 +1,7 @@  - net80;net70;net60;netstandard2.0;netstandard2.1;net35;net40;net45;net47 + net80;net70;net60;netstandard2.0;netstandard2.1;net47 https://github.com/aaubry/YamlDotNet https://github.com/aaubry/YamlDotNet @@ -23,10 +23,6 @@ $(TargetFramework) - - unitysubset3.5 - - 1591;1574;8600;8602;8604 @@ -56,31 +52,10 @@ - - - - - - - - - - - 4.3.0 - - - - - - - $(MSBuildProjectDirectory)/../BuildUtils.UnityPrerequisites/Unity Subset v3.5 - $(DefineConstants);UNITY - - $(DefineConstants);RELEASE;TRACE;SIGNED false @@ -88,10 +63,6 @@ true - true @@ -100,8 +71,6 @@ - - diff --git a/build/common.props b/build/common.props deleted file mode 100644 index 8bf719f2d..000000000 --- a/build/common.props +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/tools/aot/Dockerfile b/tools/aot/Dockerfile deleted file mode 100644 index d673aa7df..000000000 --- a/tools/aot/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM mono:6.12-slim - -RUN mono --aot=full /usr/lib/mono/4.5/mscorlib.dll && \ - mono --aot=full /usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll && \ - mono --aot=full /usr/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll && \ - mono --aot=full /usr/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll && \ - mono --aot=full /usr/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll && \ - mono --aot=full /usr/lib/mono/gac/System.Security/4.0.0.0__b03f5f7f11d50a3a/System.Security.dll && \ - mono --aot=full /usr/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll && \ - mono --aot=full /usr/lib/mono/gac/System.Numerics/4.0.0.0__b77a5c561934e089/System.Numerics.dll diff --git a/tools/aot/build.ps1 b/tools/aot/build.ps1 deleted file mode 100644 index 5e577bae4..000000000 --- a/tools/aot/build.ps1 +++ /dev/null @@ -1,2 +0,0 @@ - -docker build . -t "aaubry/mono-aot" diff --git a/tools/build/BuildDefinition.cs b/tools/build/BuildDefinition.cs index 059aa1df5..45ffcc493 100644 --- a/tools/build/BuildDefinition.cs +++ b/tools/build/BuildDefinition.cs @@ -135,28 +135,7 @@ public static SuccessfulUnitTests UnitTest(Options options, SuccessfulBuild _) return default; } - public static SuccessfulAotTests AotTest(Options options, SuccessfulBuild _) - { - var testsDir = Path.Combine(BasePath, "YamlDotNet.AotTest"); - - try - { - Run("docker", $"run --rm -v {testsDir}:/build -w /build aaubry/mono-aot bash ./run.sh"); - } - catch (NonZeroExitCodeException ex) when (options.Host == Host.AppVeyor && ex.ExitCode == -1) - { - // Appveyor fails with exit code -1 for some reason... - var realExitCode = int.Parse(File.ReadAllLines(Path.Combine(testsDir, "exitcode.txt")).First(), CultureInfo.InvariantCulture); - if (realExitCode != 0) - { - throw new NonZeroExitCodeException(realExitCode); - } - } - - return default; - } - - public static List Pack(Options options, GitVersion version, SuccessfulUnitTests _, SuccessfulAotTests __) + public static List Pack(Options options, GitVersion version, SuccessfulUnitTests _) { var result = new List(); var verbosity = options.Verbose ? "detailed" : "minimal"; @@ -550,7 +529,6 @@ public bool Equals(Version? other) public struct MetadataSet { } public struct SuccessfulBuild { } - public struct SuccessfulAotTests { } public struct SuccessfulUnitTests { } public class ScaffoldedRelease From 613627ebc05cafc825300a84948f3c2947c4797c Mon Sep 17 00:00:00 2001 From: Edward Cooke Date: Mon, 22 Jan 2024 11:18:18 -0700 Subject: [PATCH 2/3] Updated build project to net80 and new nugets --- tools/build/BuildDefinition.cs | 58 +++++++++++++++++++--------------- tools/build/Program.cs | 26 +++++++++++---- tools/build/build.csproj | 6 ++-- 3 files changed, 54 insertions(+), 36 deletions(-) diff --git a/tools/build/BuildDefinition.cs b/tools/build/BuildDefinition.cs index 45ffcc493..ee056df01 100644 --- a/tools/build/BuildDefinition.cs +++ b/tools/build/BuildDefinition.cs @@ -24,7 +24,7 @@ namespace build { public static class BuildDefinition { - public static GitVersion ResolveVersion(Options options, PreviousReleases releases) + public static async Task ResolveVersion(Options options, PreviousReleases releases) { GitVersion version; if (ForcedVersion != null) @@ -36,9 +36,10 @@ public static GitVersion ResolveVersion(Options options, PreviousReleases releas string versionJson; try { - versionJson = Read("dotnet", $"gitversion /nofetch{(options.Verbose ? " /diag" : "")}", BasePath); + var result = await ReadAsync("dotnet", $"gitversion /nofetch{(options.Verbose ? " /diag" : "")}", BasePath); + versionJson = result.StandardOutput; } - catch (NonZeroExitCodeException) + catch (ExitCodeException) { Run("dotnet", "gitversion /nofetch /diag", BasePath); throw; @@ -90,7 +91,7 @@ public static GitVersion ResolveVersion(Options options, PreviousReleases releas return version; } - public static void SetBuildVersion(Options options, GitVersion version) + public static Task SetBuildVersion(Options options, GitVersion version) { switch (options.Host) { @@ -99,9 +100,11 @@ public static void SetBuildVersion(Options options, GitVersion version) Run("appveyor", $"UpdateBuild -Version {version.NuGetVersion}.{buildNumber}"); break; } + + return Task.CompletedTask; } - public static MetadataSet SetMetadata(GitVersion version) + public static Task SetMetadata(GitVersion version) { var templatePath = Path.Combine(BasePath, "YamlDotNet", "Properties", "AssemblyInfo.template"); WriteVerbose($"Using template {templatePath}"); @@ -116,26 +119,26 @@ public static MetadataSet SetMetadata(GitVersion version) WriteVerbose($"Writing metadata to {asssemblyInfoPath}"); File.WriteAllText(asssemblyInfoPath, assemblyInfo); - return default; + return Task.FromResult(new MetadataSet()); } - public static SuccessfulBuild Build(Options options, MetadataSet _) + public static Task Build(Options options, MetadataSet _) { var verbosity = options.Verbose ? "detailed" : "minimal"; Run("dotnet", $"build YamlDotNet.sln --configuration Release --verbosity {verbosity}", BasePath); - return default; + return Task.FromResult(new SuccessfulBuild()); } - public static SuccessfulUnitTests UnitTest(Options options, SuccessfulBuild _) + public static Task UnitTest(Options options, SuccessfulBuild _) { var verbosity = options.Verbose ? "detailed" : "minimal"; Run("dotnet", $"test YamlDotNet.Test.csproj --no-build --configuration Release --verbosity {verbosity}", Path.Combine(BasePath, "YamlDotNet.Test")); - return default; + return Task.FromResult(new SuccessfulUnitTests()); } - public static List Pack(Options options, GitVersion version, SuccessfulUnitTests _) + public static Task> Pack(Options options, GitVersion version, SuccessfulUnitTests _) { var result = new List(); var verbosity = options.Verbose ? "detailed" : "minimal"; @@ -152,10 +155,10 @@ public static List Pack(Options options, GitVersion version, Succe result.Add(new NuGetPackage(packagePath, "YamlDotNet.Analyzers.StaticGenerator")); } - return result; + return Task.FromResult(result); } - public static void Publish(Options options, GitVersion version, List packages) + public static Task Publish(Options options, GitVersion version, List packages) { var apiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY"); if (string.IsNullOrEmpty(apiKey)) @@ -187,6 +190,8 @@ public static void Publish(Options options, GitVersion version, List ScaffoldReleaseNotes(GitVersion version, PreviousReleases releases) { if (version.IsPreRelease) { @@ -220,7 +225,7 @@ public static ScaffoldedRelease ScaffoldReleaseNotes(GitVersion version, Previou // Get the git log to scaffold the release notes string? currentHash = null; - var commits = ReadLines("git", $"rev-list v{previousVersion}..HEAD --first-parent --reverse --pretty=tformat:%B") + var commits = (await ReadLines("git", $"rev-list v{previousVersion}..HEAD --first-parent --reverse --pretty=tformat:%B")) .Select(l => { var match = Regex.Match(l, "^commit (?[a-f0-9]+)$"); @@ -304,10 +309,10 @@ public static async Task LinkPullRequestsToReleases(GitVersion version) } } - public static PreviousReleases DiscoverPreviousReleases() + public static async Task DiscoverPreviousReleases() { // Find previous release - var releases = ReadLines("git", "tag --list --merged origin/master --format=\"%(refname:short)\" v*") + var releases = (await ReadLines("git", "tag --list --merged origin/master --format=\"%(refname:short)\" v*")) .Select(tag => Regex.Match(tag.TrimEnd('\r'), @"^v(?\d+)\.(?\d+)\.(?\d+)$")) .Where(m => m.Success) .Select(match => new Version( @@ -325,7 +330,7 @@ public static PreviousReleases DiscoverPreviousReleases() return previousReleases; } - public static void Document(Options options) + public static Task Document(Options options) { var samplesProjectDir = Path.Combine(BasePath, "YamlDotNet.Samples"); var samplesOutputDir = Path.Combine(BasePath, "..", "YamlDotNet.wiki"); @@ -338,16 +343,16 @@ public static void Document(Options options) const string ns = "http://microsoft.com/schemas/VisualStudio/TeamTest/2010"; var testDefinitions = report.Root - .Element(XName.Get("TestDefinitions", ns)) + .Element(XName.Get("TestDefinitions", ns))! .Elements(XName.Get("UnitTest", ns)) .Select(e => { var testMethod = e.Element(XName.Get("TestMethod", ns)); - var sampleClassName = testMethod.Attribute("className").Value; - var sampleMethodName = testMethod.Attribute("name").Value; + var sampleClassName = testMethod.Attribute("className")!.Value; + var sampleMethodName = testMethod.Attribute("name")!.Value; - var testMethodAssembly = Assembly.LoadFrom(testMethod.Attribute("codeBase").Value); + var testMethodAssembly = Assembly.LoadFrom(testMethod.Attribute("codeBase")!.Value); var sampleClass = testMethodAssembly .GetType(sampleClassName, true)!; @@ -364,8 +369,8 @@ public static void Document(Options options) return new { - Id = e.Attribute("id").Value, - Name = e.Attribute("name").Value, + Id = e.Attribute("id")!.Value, + Name = e.Attribute("name")!.Value, Description = description, Code = File.ReadAllText(Path.Combine(samplesProjectDir, $"{sampleClass.Name}.cs")), FileName = $"Samples.{sampleClass.Name}.md", @@ -373,11 +378,11 @@ public static void Document(Options options) }); var testResults = report.Root - .Element(XName.Get("Results", ns)) + .Element(XName.Get("Results", ns))! .Elements(XName.Get("UnitTestResult", ns)) .Select(e => new { - TestId = e.Attribute("testId").Value, + TestId = e.Attribute("testId")!.Value, Output = e .Element(XName.Get("Output", ns)) ?.Element(XName.Get("StdOut", ns)) @@ -435,6 +440,7 @@ public static void Document(Options options) * [Building Custom Formatters for .Net Core (Yaml Formatters)](http://www.fiyazhasan.me/building-custom-formatters-for-net-core-yaml-formatters/) by @FiyazBinHasan "); + return Task.CompletedTask; } private static string GitHubRepository diff --git a/tools/build/Program.cs b/tools/build/Program.cs index f6918d49a..60fd98eac 100644 --- a/tools/build/Program.cs +++ b/tools/build/Program.cs @@ -99,8 +99,17 @@ private static void RegisterTargets() providerTargets.Add(returnType, targetMethod.Name); } - var action = Expression.Lambda(actionExpression); - targets.Add((targetMethod.Name, action.Compile(), dependencies)); + try + { + var action = Expression.Lambda(actionExpression); + targets.Add((targetMethod.Name, action.Compile(), dependencies)); + } + catch (Exception exception) + { + Console.WriteLine("Error: " + exception); + Console.WriteLine("TargetMethod: " + targetMethod.Name); + throw; + } } foreach (var (name, action, dependencies) in targets) @@ -318,11 +327,14 @@ private static void Write(string text, string color) Console.WriteLine($"{color}{text}{palette.Reset}"); } - public static IEnumerable ReadLines(string name, string? args = null, string? workingDirectory = null) => SimpleExec.Command - .Read(name, args, workingDirectory) - .Split('\n') - .Select(l => l.TrimEnd('\r')); - + public static async Task> ReadLines(string name, string args, string? workingDirectory = null) + { + var read = await SimpleExec.Command.ReadAsync(name, args, workingDirectory ?? string.Empty); + var result = read.StandardOutput + .Split('\n') + .Select(l => l.TrimEnd('\r')); + return result; + } public static string UnIndent(string text) { var lines = text diff --git a/tools/build/build.csproj b/tools/build/build.csproj index 63b9f93fc..25deec28c 100644 --- a/tools/build/build.csproj +++ b/tools/build/build.csproj @@ -2,15 +2,15 @@ Exe - netcoreapp3.1 + net80 AnyCPU Enable - - + + From 8e75e9e34584a6707f440429d3e95432a73257b3 Mon Sep 17 00:00:00 2001 From: Edward Cooke Date: Mon, 22 Jan 2024 11:30:19 -0700 Subject: [PATCH 3/3] Added .net8 to the nuspec and removed old frameworks --- YamlDotNet/YamlDotNet.nuspec | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/YamlDotNet/YamlDotNet.nuspec b/YamlDotNet/YamlDotNet.nuspec index f4f76867a..e5f4046d1 100644 --- a/YamlDotNet/YamlDotNet.nuspec +++ b/YamlDotNet/YamlDotNet.nuspec @@ -14,31 +14,27 @@ yaml parser development library serialization - - + - - - - - - + + +