Skip to content

Fix .NET Framework builds #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ echo "build: Build started"
Push-Location $PSScriptRoot

if(Test-Path .\artifacts) {
echo "build: Cleaning ./artifacts"
Remove-Item ./artifacts -Force -Recurse
echo "build: Cleaning .\artifacts"
Remove-Item .\artifacts -Force -Recurse
}

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

echo "build: Package version suffix is $suffix"
echo "build: Build version suffix is $buildSuffix"
echo "build: Build version suffix is $buildSuffix"

foreach ($src in gci src/*) {
foreach ($src in ls src/*) {
Push-Location $src

echo "build: Packaging project in $src"

& dotnet build -c Release --version-suffix=$buildSuffix

if($suffix) {
& dotnet pack -c Release --include-source --no-build -o ../../artifacts --version-suffix=$suffix
& dotnet build -c Release --version-suffix=$buildSuffix -p:EnableSourceLink=true
if ($suffix) {
& dotnet pack -c Release -o ..\..\artifacts --version-suffix=$suffix --no-build
} else {
& dotnet pack -c Release --include-source --no-build -o ../../artifacts
& dotnet pack -c Release -o ..\..\artifacts --no-build
}
if($LASTEXITCODE -ne 0) { exit 1 }
if($LASTEXITCODE -ne 0) { throw "build failed" }

Pop-Location
}

foreach ($test in gci test/*.Tests) {
foreach ($test in ls test/*.Tests) {
Push-Location $test

echo "build: Testing project in $test"

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

Pop-Location
}

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

echo "build: Building performance test project in $test"
echo "build: Building project in $test"

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

Pop-Location
}
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Expressions/Expressions/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#if NETSTANDARD2_0
#if NO_CI_STRING_CONTAINS

namespace Serilog.Expressions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Serilog.Expressions/Expressions/Runtime/Coerce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public static bool IsTrue(LogEventPropertyValue? value)
return Boolean(value, out var b) && b;
}

public static bool String(LogEventPropertyValue? value, [MaybeNullWhen(false)] out string str)
public static bool String(LogEventPropertyValue? value, [NotNullWhen(true)] out string? str)
{
if (value is ScalarValue sv)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ static bool UnboxedEqualHelper(StringComparison sc, LogEventPropertyValue? left,
for (var i = 0; i < arr.Elements.Count; ++i)
{
var element = arr.Elements[i];
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (element != null && UnboxedEqualHelper(sc, element, item))
return ConstantTrue;
}
Expand Down Expand Up @@ -350,6 +351,7 @@ public static LogEventPropertyValue IsDefined(LogEventPropertyValue? value)
{
// The lack of eager numeric type coercion means that here, `sv` may logically equal one
// of the keys, but not be equal according to the dictionary's `IEqualityComparer`.
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
var entry = dict.Elements.FirstOrDefault(kv => kv.Key != null && UnboxedEqualHelper(sc, kv.Key, sv));
return entry.Value; // KVP is a struct; default is a pair of nulls.
}
Expand Down
17 changes: 13 additions & 4 deletions src/Serilog.Expressions/Serilog.Expressions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>An embeddable mini-language for filtering, enriching, and formatting Serilog
events, ideal for use with JSON or XML configuration.</Description>
<VersionPrefix>5.0.1</VersionPrefix>
<VersionPrefix>5.0.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<!-- .NET Framework version targeting is frozen at these two TFMs. -->
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net471;net462</TargetFrameworks>
Expand All @@ -22,12 +22,21 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);NO_CI_STRING_CONTAINS</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net471' ">
<DefineConstants>$(DefineConstants);NO_CI_STRING_CONTAINS</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
<DefineConstants>$(DefineConstants);NO_CI_STRING_CONTAINS</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="Nullable" Version="1.3.1" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\assets\icon.png" Pack="true" Visible="false" PackagePath="" />
<None Include="..\..\README.md" Pack="true" Visible="false" PackagePath="" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ undefined() = undefined() ci ⇶ undefined()
'test' like '%' ⇶ true
'test' like 't%s%' ⇶ true
'test' like 'es' ⇶ false
'test' like '%' ⇶ true
'test' like '' ⇶ false
'' like '' ⇶ true

Expand Down
4 changes: 2 additions & 2 deletions test/Serilog.Expressions.Tests/ExpressionTranslationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ namespace Serilog.Expressions.Tests;

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

[Theory]
[MemberData(nameof(ExpressionEvaluationCases))]
[MemberData(nameof(ExpressionTranslationCases))]
public void ExpressionsAreCorrectlyTranslated(string expr, string expected)
{
var parsed = new ExpressionParser().Parse(expr);
Expand Down