Skip to content

Commit 2a0a5b4

Browse files
authored
Merge pull request #118 from nblumhardt/build-fix
Fix .NET Framework builds
2 parents b63e24c + d67cfab commit 2a0a5b4

File tree

7 files changed

+32
-23
lines changed

7 files changed

+32
-23
lines changed

Build.ps1

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ echo "build: Build started"
33
Push-Location $PSScriptRoot
44

55
if(Test-Path .\artifacts) {
6-
echo "build: Cleaning ./artifacts"
7-
Remove-Item ./artifacts -Force -Recurse
6+
echo "build: Cleaning .\artifacts"
7+
Remove-Item .\artifacts -Force -Recurse
88
}
99

1010
& dotnet restore --no-cache
@@ -16,43 +16,42 @@ $commitHash = $(git rev-parse --short HEAD)
1616
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]
1717

1818
echo "build: Package version suffix is $suffix"
19-
echo "build: Build version suffix is $buildSuffix"
19+
echo "build: Build version suffix is $buildSuffix"
2020

21-
foreach ($src in gci src/*) {
21+
foreach ($src in ls src/*) {
2222
Push-Location $src
2323

2424
echo "build: Packaging project in $src"
2525

26-
& dotnet build -c Release --version-suffix=$buildSuffix
27-
28-
if($suffix) {
29-
& dotnet pack -c Release --include-source --no-build -o ../../artifacts --version-suffix=$suffix
26+
& dotnet build -c Release --version-suffix=$buildSuffix -p:EnableSourceLink=true
27+
if ($suffix) {
28+
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --no-build
3029
} else {
31-
& dotnet pack -c Release --include-source --no-build -o ../../artifacts
30+
& dotnet pack -c Release -o ..\..\artifacts --no-build
3231
}
33-
if($LASTEXITCODE -ne 0) { exit 1 }
32+
if($LASTEXITCODE -ne 0) { throw "build failed" }
3433

3534
Pop-Location
3635
}
3736

38-
foreach ($test in gci test/*.Tests) {
37+
foreach ($test in ls test/*.Tests) {
3938
Push-Location $test
4039

4140
echo "build: Testing project in $test"
4241

4342
& dotnet test -c Release
44-
if($LASTEXITCODE -ne 0) { exit 3 }
43+
if($LASTEXITCODE -ne 0) { throw "tests failed" }
4544

4645
Pop-Location
4746
}
4847

4948
foreach ($test in ls test/*.PerformanceTests) {
5049
Push-Location $test
5150

52-
echo "build: Building performance test project in $test"
51+
echo "build: Building project in $test"
5352

5453
& dotnet build -c Release
55-
if($LASTEXITCODE -ne 0) { exit 2 }
54+
if($LASTEXITCODE -ne 0) { throw "performance test build failed" }
5655

5756
Pop-Location
5857
}

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: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<Description>An embeddable mini-language for filtering, enriching, and formatting Serilog
55
events, ideal for use with JSON or XML configuration.</Description>
6-
<VersionPrefix>5.0.1</VersionPrefix>
6+
<VersionPrefix>5.0.0</VersionPrefix>
77
<Authors>Serilog Contributors</Authors>
88
<!-- .NET Framework version targeting is frozen at these two TFMs. -->
99
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net471;net462</TargetFrameworks>
@@ -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>

test/Serilog.Expressions.Tests/Cases/expression-evaluation-cases.asv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ undefined() = undefined() ci ⇶ undefined()
302302
'test' like '%' ⇶ true
303303
'test' like 't%s%' ⇶ true
304304
'test' like 'es' ⇶ false
305-
'test' like '%' ⇶ true
306305
'test' like '' ⇶ false
307306
'' like '' ⇶ true
308307

test/Serilog.Expressions.Tests/ExpressionTranslationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ namespace Serilog.Expressions.Tests;
77

88
public class ExpressionTranslationTests
99
{
10-
public static IEnumerable<object[]> ExpressionEvaluationCases =>
10+
public static IEnumerable<object[]> ExpressionTranslationCases =>
1111
AsvCases.ReadCases("translation-cases.asv");
1212

1313
[Theory]
14-
[MemberData(nameof(ExpressionEvaluationCases))]
14+
[MemberData(nameof(ExpressionTranslationCases))]
1515
public void ExpressionsAreCorrectlyTranslated(string expr, string expected)
1616
{
1717
var parsed = new ExpressionParser().Parse(expr);

0 commit comments

Comments
 (0)