From 5259ad92c74bdba3f8fdfc098b36391ee0bad218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Onak?= Date: Wed, 22 Jan 2025 20:16:48 +0100 Subject: [PATCH 1/3] Update to .NET8 SDK --- global.json | 2 +- samples/ObjectAssertions.Sample/ObjectAssertions.Sample.csproj | 2 +- .../ObjectAssertions.Abstractions.csproj | 2 +- src/ObjectAssertions/ObjectAssertions.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/global.json b/global.json index 6ca92cf..4c8007c 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.102", + "version": "8.0.405", "rollForward": "latestFeature" } } \ No newline at end of file diff --git a/samples/ObjectAssertions.Sample/ObjectAssertions.Sample.csproj b/samples/ObjectAssertions.Sample/ObjectAssertions.Sample.csproj index ec4d7fa..718bdf9 100644 --- a/samples/ObjectAssertions.Sample/ObjectAssertions.Sample.csproj +++ b/samples/ObjectAssertions.Sample/ObjectAssertions.Sample.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 enable false diff --git a/src/ObjectAssertions.Abstractions/ObjectAssertions.Abstractions.csproj b/src/ObjectAssertions.Abstractions/ObjectAssertions.Abstractions.csproj index bd1c243..6b29f56 100644 --- a/src/ObjectAssertions.Abstractions/ObjectAssertions.Abstractions.csproj +++ b/src/ObjectAssertions.Abstractions/ObjectAssertions.Abstractions.csproj @@ -3,7 +3,7 @@ netstandard2.0 true - 8 + 11 enable diff --git a/src/ObjectAssertions/ObjectAssertions.csproj b/src/ObjectAssertions/ObjectAssertions.csproj index 410e200..36cb2c4 100644 --- a/src/ObjectAssertions/ObjectAssertions.csproj +++ b/src/ObjectAssertions/ObjectAssertions.csproj @@ -5,7 +5,7 @@ enable true true - 9 + 11 0.0.0-preview1 From e372858f8f6c82303176aa1e767979184893a659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Onak?= Date: Wed, 22 Jan 2025 20:17:03 +0100 Subject: [PATCH 2/3] Fix identation of auto-generated header --- src/ObjectAssertions/Generator/ClassGenerator.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/ObjectAssertions/Generator/ClassGenerator.cs b/src/ObjectAssertions/Generator/ClassGenerator.cs index 7908dbf..65b7a75 100644 --- a/src/ObjectAssertions/Generator/ClassGenerator.cs +++ b/src/ObjectAssertions/Generator/ClassGenerator.cs @@ -80,12 +80,13 @@ private string GenerateSource() private void GenerateAutogeneratedHeader(IndentedTextWriter sourceWriter) { - string header = @" - //------------------------------------------------------------------------------ - // - // This code was generated by a source gnerator. - // - //------------------------------------------------------------------------------"; + string header = """ + //------------------------------------------------------------------------------ + // + // This code was generated by a source gnerator. + // + //------------------------------------------------------------------------------ + """; sourceWriter.WriteLine(header); } From 3fff6a35d23bf2719168187b310ed01a92cee4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Onak?= Date: Wed, 22 Jan 2025 20:17:13 +0100 Subject: [PATCH 3/3] Handle obsolete properties --- .../ObjectAssertions.Sample/ObjectAssertions.Sample.csproj | 1 + samples/ObjectAssertions.Sample/Program.cs | 5 +++++ src/ObjectAssertions/Generator/ClassGenerator.cs | 1 + 3 files changed, 7 insertions(+) diff --git a/samples/ObjectAssertions.Sample/ObjectAssertions.Sample.csproj b/samples/ObjectAssertions.Sample/ObjectAssertions.Sample.csproj index 718bdf9..dea1281 100644 --- a/samples/ObjectAssertions.Sample/ObjectAssertions.Sample.csproj +++ b/samples/ObjectAssertions.Sample/ObjectAssertions.Sample.csproj @@ -4,6 +4,7 @@ net8.0 enable false + true diff --git a/samples/ObjectAssertions.Sample/Program.cs b/samples/ObjectAssertions.Sample/Program.cs index 76e5e95..92bc4b6 100644 --- a/samples/ObjectAssertions.Sample/Program.cs +++ b/samples/ObjectAssertions.Sample/Program.cs @@ -1,4 +1,5 @@ using ObjectAssertions.Abstractions; +using System; using Xunit; using static ObjectAssertions.Sample.ObjectToAssert; @@ -22,6 +23,9 @@ public record ObjectToAssert : Base public int? NullableNumber { get; set; } = 5; public NestedObject NestedObjectValue { get; set; } = new NestedObject(); + [Obsolete] + public string ObsoleteValue { get; set; } = "I'm obsolete"; + public enum ExampleEnum { Option1, Option2, Option3 }; public record NestedObject(int NestedInt = 5, string NestedString = "ubuaa"); @@ -58,6 +62,7 @@ public void HowTo() IntegerNumber = i => Assert.Equal(30, i), NullableNumber = n => Assert.Equal(5, n), StringValue = s => Assert.Equal("Hello world", s), + ObsoleteValue = o => Assert.Equal("I'm obsolete", o), // Obsolete warnings are ignored in generated code NestedObjectValue = n => new NestedObjectAssertions(n) { NestedInt = ObjectAssertionsHelpers.Ignore("Out of test scope"), diff --git a/src/ObjectAssertions/Generator/ClassGenerator.cs b/src/ObjectAssertions/Generator/ClassGenerator.cs index 65b7a75..a44b96b 100644 --- a/src/ObjectAssertions/Generator/ClassGenerator.cs +++ b/src/ObjectAssertions/Generator/ClassGenerator.cs @@ -86,6 +86,7 @@ private void GenerateAutogeneratedHeader(IndentedTextWriter sourceWriter) // This code was generated by a source gnerator. // //------------------------------------------------------------------------------ + #pragma warning disable CS0612 """; sourceWriter.WriteLine(header); }