Skip to content

Commit 457d5f5

Browse files
committed
Fix .NET Framework builds
1 parent b63e24c commit 457d5f5

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

Build.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ foreach ($src in gci src/*) {
3030
} else {
3131
& dotnet pack -c Release --include-source --no-build -o ../../artifacts
3232
}
33-
if($LASTEXITCODE -ne 0) { exit 1 }
33+
if($LASTEXITCODE -ne 0) { throw "build failed" }
3434

3535
Pop-Location
3636
}
@@ -41,7 +41,7 @@ foreach ($test in gci test/*.Tests) {
4141
echo "build: Testing project in $test"
4242

4343
& dotnet test -c Release
44-
if($LASTEXITCODE -ne 0) { exit 3 }
44+
if($LASTEXITCODE -ne 0) { throw "test failed" }
4545

4646
Pop-Location
4747
}
@@ -52,7 +52,7 @@ foreach ($test in ls test/*.PerformanceTests) {
5252
echo "build: Building performance test project in $test"
5353

5454
& dotnet build -c Release
55-
if($LASTEXITCODE -ne 0) { exit 2 }
55+
if($LASTEXITCODE -ne 0) { throw "perf test build failed" }
5656

5757
Pop-Location
5858
}

src/Serilog.Expressions/Expressions/Helpers.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#if NETSTANDARD2_0
15+
#if NO_CI_STRING_CONTAINS
1616

1717
namespace Serilog.Expressions
1818
{

src/Serilog.Expressions/Expressions/Runtime/Coerce.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static bool IsTrue(LogEventPropertyValue? value)
6060
return Boolean(value, out var b) && b;
6161
}
6262

63-
public static bool String(LogEventPropertyValue? value, [MaybeNullWhen(false)] out string str)
63+
public static bool String(LogEventPropertyValue? value, [NotNullWhen(true)] out string? str)
6464
{
6565
if (value is ScalarValue sv)
6666
{

src/Serilog.Expressions/Expressions/Runtime/RuntimeOperators.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ static bool UnboxedEqualHelper(StringComparison sc, LogEventPropertyValue? left,
206206
for (var i = 0; i < arr.Elements.Count; ++i)
207207
{
208208
var element = arr.Elements[i];
209+
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
209210
if (element != null && UnboxedEqualHelper(sc, element, item))
210211
return ConstantTrue;
211212
}
@@ -350,6 +351,7 @@ public static LogEventPropertyValue IsDefined(LogEventPropertyValue? value)
350351
{
351352
// The lack of eager numeric type coercion means that here, `sv` may logically equal one
352353
// of the keys, but not be equal according to the dictionary's `IEqualityComparer`.
354+
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
353355
var entry = dict.Elements.FirstOrDefault(kv => kv.Key != null && UnboxedEqualHelper(sc, kv.Key, sv));
354356
return entry.Value; // KVP is a struct; default is a pair of nulls.
355357
}

src/Serilog.Expressions/Serilog.Expressions.csproj

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,21 @@
2222
<PackageReadmeFile>README.md</PackageReadmeFile>
2323
</PropertyGroup>
2424

25+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
26+
<DefineConstants>$(DefineConstants);NO_CI_STRING_CONTAINS</DefineConstants>
27+
</PropertyGroup>
28+
29+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net471' ">
30+
<DefineConstants>$(DefineConstants);NO_CI_STRING_CONTAINS</DefineConstants>
31+
</PropertyGroup>
32+
33+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
34+
<DefineConstants>$(DefineConstants);NO_CI_STRING_CONTAINS</DefineConstants>
35+
</PropertyGroup>
36+
2537
<ItemGroup>
2638
<PackageReference Include="Serilog" Version="4.0.0" />
2739
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="All" />
28-
</ItemGroup>
29-
30-
<ItemGroup>
3140
<None Include="..\..\assets\icon.png" Pack="true" Visible="false" PackagePath="" />
3241
<None Include="..\..\README.md" Pack="true" Visible="false" PackagePath="" />
3342
</ItemGroup>

0 commit comments

Comments
 (0)