Skip to content

Commit 006090b

Browse files
authored
Merge pull request #976 from EdwardCooke/ec-warningsaserrors
Warnings as errors and compiler error cleanup +semver:fix
2 parents f323881 + a39e88a commit 006090b

24 files changed

+406
-300
lines changed

Directory.Build.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
</PropertyGroup>
1111

1212
<PropertyGroup>
13+
<WarningLevel>9999</WarningLevel>
14+
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
1315
<LangVersion>12.0</LangVersion>
1416
</PropertyGroup>
17+
18+
<PropertyGroup Condition="$(Configuration) == 'Release'" Label="Code style enforcement">
19+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
20+
</PropertyGroup>
1521

1622
</Project>

Directory.Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
1010
<PackageVersion Include="FakeItEasy" Version="6.2.1" />
1111
<PackageVersion Include="FluentAssertions" Version="4.19.2" />
12+
<PackageVersion Include="FSharp.Core" Version="8.0.400" />
1213
<PackageVersion Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
1314
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" />
1415
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFrameworks>net8.0;net472</TargetFrameworks>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<Nullable>enable</Nullable>
8-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFrameworks>net8.0;net472</TargetFrameworks>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
99

10-
<ItemGroup>
11-
<PackageReference Include="BenchmarkDotNet" />
12-
</ItemGroup>
10+
<ItemGroup>
11+
<PackageReference Include="BenchmarkDotNet" />
12+
</ItemGroup>
1313

14-
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
15-
<PackageReference Include="System.Collections.Immutable" />
16-
<PackageReference Include="System.Reflection.Metadata" />
17-
</ItemGroup>
14+
<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
15+
<PackageReference Include="System.Collections.Immutable" />
16+
<PackageReference Include="System.Reflection.Metadata" />
17+
</ItemGroup>
1818

19-
<ItemGroup>
20-
<ProjectReference Include="..\YamlDotNet\YamlDotNet.csproj" />
21-
</ItemGroup>
19+
<ItemGroup>
20+
<ProjectReference Include="..\YamlDotNet\YamlDotNet.csproj" />
21+
</ItemGroup>
2222

23-
<ItemGroup>
24-
<None Update="Resources\*" CopyToOutputDirectory="PreserveNewest" />
25-
</ItemGroup>
23+
<ItemGroup>
24+
<None Update="Resources\*" CopyToOutputDirectory="PreserveNewest" />
25+
</ItemGroup>
2626

2727
</Project>

YamlDotNet.Core7AoTCompileTest.Model/ExternalModel.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
namespace YamlDotNet.Core7AoTCompileTest.Model;
1+
// This file is part of YamlDotNet - A .NET library for YAML.
2+
// Copyright (c) Antoine Aubry and contributors
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy of
5+
// this software and associated documentation files (the "Software"), to deal in
6+
// the Software without restriction, including without limitation the rights to
7+
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8+
// of the Software, and to permit persons to whom the Software is furnished to do
9+
// so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in all
12+
// copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
// SOFTWARE.
21+
22+
namespace YamlDotNet.Core7AoTCompileTest.Model;
223

324
public class ExternalModel
425
{

YamlDotNet.Core7AoTCompileTest.Model/YamlDotNet.Core7AoTCompileTest.Model.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7-
<WarningsAsErrors>true</WarningsAsErrors>
87
</PropertyGroup>
98

109
</Project>

YamlDotNet.Core7AoTCompileTest/YamlDotNet.Core7AoTCompileTest.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<PublishAot>true</PublishAot>
77
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
88
<Nullable>enable</Nullable>
9-
<WarningsAsErrors>true</WarningsAsErrors>
109
</PropertyGroup>
1110

1211
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug-AOT|AnyCPU' ">
@@ -17,7 +16,6 @@
1716
<OutputPath>bin\Debug\</OutputPath>
1817
<DefineConstants>DEBUG;TRACE</DefineConstants>
1918
<ErrorReport>prompt</ErrorReport>
20-
<WarningLevel>4</WarningLevel>
2119
</PropertyGroup>
2220

2321
<ItemGroup>

YamlDotNet.Fsharp.Test/DeserializerTests.fs

Lines changed: 88 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,33 @@ open YamlDotNet.Serialization.NamingConventions
88
open System.ComponentModel
99

1010
[<CLIMutable>]
11-
type Spec = {
12-
EngineType: string
13-
DriveType: string
14-
}
11+
type Spec =
12+
{
13+
EngineType: string
14+
DriveType: string
15+
}
1516

1617
[<CLIMutable>]
17-
type Car = {
18-
Name: string
19-
Year: int
20-
Spec: Spec option
21-
Nickname: string option
22-
}
18+
type Car =
19+
{
20+
Name: string
21+
Year: int
22+
Spec: Spec option
23+
Nickname: string option
24+
}
2325

2426
[<CLIMutable>]
25-
type Person = {
26-
Name: string
27-
MomentOfBirth: DateTime
28-
Cars: Car array
29-
}
27+
type Person =
28+
{
29+
Name: string
30+
MomentOfBirth: DateTime
31+
Cars: Car array
32+
}
3033

3134
[<Fact>]
32-
let Deserialize_YamlWithScalarOptions() =
33-
let yaml = """
35+
let Deserialize_YamlWithScalarOptions () =
36+
let yaml =
37+
"""
3438
name: Jack
3539
momentOfBirth: 1983-04-21T20:21:03.0041599Z
3640
cars:
@@ -40,21 +44,24 @@ cars:
4044
- name: Honda
4145
year: 2021
4246
"""
43-
let sut = DeserializerBuilder()
44-
.WithNamingConvention(CamelCaseNamingConvention.Instance)
45-
.Build()
47+
48+
let sut =
49+
DeserializerBuilder()
50+
.WithNamingConvention(CamelCaseNamingConvention.Instance)
51+
.Build()
4652

4753
let person = sut.Deserialize<Person>(yaml)
4854
Assert.Equal("Jack", person.Name)
4955
Assert.Equal(2, person.Cars.Length)
5056
Assert.Equal("Mercedes", person.Cars[0].Name)
51-
Assert.Equal(Some "Jessy", person.Cars[0].Nickname)// |> should equal (Some "Jessy")
57+
Assert.Equal(Some "Jessy", person.Cars[0].Nickname) // |> should equal (Some "Jessy")
5258
Assert.Equal("Honda", person.Cars[1].Name)
5359
Assert.Equal(None, person.Cars[1].Nickname)
5460

5561
[<Fact>]
56-
let Deserialize_YamlWithObjectOptions() =
57-
let yaml = """
62+
let Deserialize_YamlWithObjectOptions () =
63+
let yaml =
64+
"""
5865
name: Jack
5966
momentOfBirth: 1983-04-21T20:21:03.0041599Z
6067
cars:
@@ -66,48 +73,56 @@ cars:
6673
- name: Honda
6774
year: 2021
6875
"""
69-
let sut = DeserializerBuilder()
70-
.WithNamingConvention(CamelCaseNamingConvention.Instance)
71-
.Build()
76+
77+
let sut =
78+
DeserializerBuilder()
79+
.WithNamingConvention(CamelCaseNamingConvention.Instance)
80+
.Build()
7281

7382
let person = sut.Deserialize<Person>(yaml)
7483
Assert.Equal("Jack", person.Name)
7584
Assert.Equal(2, person.Cars.Length)
76-
85+
7786
Assert.Equal("Mercedes", person.Cars[0].Name)
7887
Assert.NotNull(person.Cars[0].Spec)
7988
Assert.True(person.Cars[0].Spec |> Option.isSome)
8089
Assert.Equal("V6", person.Cars[0].Spec.Value.EngineType)
8190
Assert.Equal("AWD", person.Cars[0].Spec.Value.DriveType)
82-
91+
8392
Assert.Equal("Honda", person.Cars[1].Name)
8493
Assert.Null(person.Cars[1].Spec)
8594
Assert.Equal(None, person.Cars[1].Spec)
8695
Assert.Equal(None, person.Cars[1].Nickname)
8796

88-
8997
[<CLIMutable>]
90-
type TestSeq = {
91-
name: string
92-
numbers: int seq
93-
}
98+
[<NoComparison>]
99+
type TestSeq = { name: string; numbers: int seq }
94100

95101
[<Fact>]
96-
let Deserialize_YamlSeq() =
97-
let jackTheDriver = {
98-
name = "Jack"
99-
numbers = seq { 12; 2; 2 }
100-
}
101-
102-
let yaml = """name: Jack
102+
let Deserialize_YamlSeq () =
103+
let jackTheDriver =
104+
{
105+
name = "Jack"
106+
numbers =
107+
seq {
108+
12
109+
2
110+
2
111+
}
112+
}
113+
114+
let yaml =
115+
"""name: Jack
103116
numbers:
104117
- 12
105118
- 2
106119
- 2
107120
"""
108-
let sut = DeserializerBuilder()
109-
.WithNamingConvention(CamelCaseNamingConvention.Instance)
110-
.Build()
121+
122+
let sut =
123+
DeserializerBuilder()
124+
.WithNamingConvention(CamelCaseNamingConvention.Instance)
125+
.Build()
111126

112127
let person = sut.Deserialize<TestSeq>(yaml)
113128
Assert.Equal(jackTheDriver.name, person.name)
@@ -118,27 +133,28 @@ numbers:
118133
Assert.Equal(2, numbers[2])
119134

120135
[<CLIMutable>]
121-
type TestList = {
122-
name: string
123-
numbers: int list
124-
}
136+
type TestList = { name: string; numbers: int list }
125137

126138
[<Fact>]
127-
let Deserialize_YamlList() =
128-
let jackTheDriver = {
129-
name = "Jack"
130-
numbers = [ 12; 2; 2 ]
131-
}
132-
133-
let yaml = """name: Jack
139+
let Deserialize_YamlList () =
140+
let jackTheDriver =
141+
{
142+
name = "Jack"
143+
numbers = [ 12; 2; 2 ]
144+
}
145+
146+
let yaml =
147+
"""name: Jack
134148
numbers:
135149
- 12
136150
- 2
137151
- 2
138152
"""
139-
let sut = DeserializerBuilder()
140-
.WithNamingConvention(CamelCaseNamingConvention.Instance)
141-
.Build()
153+
154+
let sut =
155+
DeserializerBuilder()
156+
.WithNamingConvention(CamelCaseNamingConvention.Instance)
157+
.Build()
142158

143159
let person = sut.Deserialize<TestList>(yaml)
144160
Assert.Equal(jackTheDriver.name, person.name)
@@ -148,29 +164,29 @@ numbers:
148164
Assert.Equal(2, numbers[1])
149165
Assert.Equal(2, numbers[2])
150166

151-
152167
[<CLIMutable>]
153-
type TestArray = {
154-
name: string
155-
numbers: int array
156-
}
168+
type TestArray = { name: string; numbers: int array }
157169

158170
[<Fact>]
159-
let Deserialize_YamlArray() =
160-
let jackTheDriver = {
161-
name = "Jack"
162-
numbers = [| 12; 2; 2 |]
163-
}
164-
165-
let yaml = """name: Jack
171+
let Deserialize_YamlArray () =
172+
let jackTheDriver =
173+
{
174+
name = "Jack"
175+
numbers = [| 12; 2; 2 |]
176+
}
177+
178+
let yaml =
179+
"""name: Jack
166180
numbers:
167181
- 12
168182
- 2
169183
- 2
170184
"""
171-
let sut = DeserializerBuilder()
172-
.WithNamingConvention(CamelCaseNamingConvention.Instance)
173-
.Build()
185+
186+
let sut =
187+
DeserializerBuilder()
188+
.WithNamingConvention(CamelCaseNamingConvention.Instance)
189+
.Build()
174190

175191
let person = sut.Deserialize<TestArray>(yaml)
176192
Assert.Equal(jackTheDriver.name, person.name)

0 commit comments

Comments
 (0)