Skip to content

Commit

Permalink
ref: multi-target netcore 3.0 (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
bruno-garcia authored Dec 17, 2019
1 parent 2402423 commit 598ab4f
Show file tree
Hide file tree
Showing 23 changed files with 95 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: "{build}"
image: Visual Studio 2017
image: Visual Studio 2019
environment:
global:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1"
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: "1" # Used by the dotnet SDK prior to v3.0
DOTNET_CLI_TELEMETRY_OPTOUT: "1"
test: off
branches:
Expand Down
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
language: csharp
env:
global:
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 # Used by the dotnet SDK prior to v3.0
- DOTNET_CLI_TELEMETRY_OPTOUT=1
dotnet: 2.2.105
mono: 5.12.0
mono: 6.6.0
branches:
only:
- master
- /^release\/.*$/
matrix:
include:
- os: osx # osx_image: xcode8.3 Default Xcode 8.3.3 OS X 10.12 1.8.0_112-b16
osx_image: xcode9.2
- os: osx
osx_image: xcode11.2
- os: linux
dist: bionic
sudo: required
group: edge
script:
- curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 2.1.507
- curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --version 3.1.100
- export PATH=$PATH:~/.dotnet
- dotnet --info
- ./build.sh
after_success:
- curl -s https://codecov.io/bash > codecov
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,10 @@ The packages target **.NET Standard 2.0** and **.NET Framework 4.6.1**. That mea

Of those, we've tested (we run our unit/integration tests) against:

* .NET Framework 4.7.2 on Windows
* Mono 5.12 macOS and Linux (Travis-CI)
* .NET Core 2.1 Windows, macOS and Linux
* .NET Framework 4.8 on Windows
* Mono 6.6 on macOS and Linux
* .NET Core 2.1 on Windows, macOS and Linux
* .NET Core 3.1 on Windows, macOS and Linux

### Sentry Protocol

Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.2.105"
"version": "3.1.100"
}
}
9 changes: 6 additions & 3 deletions src/Sentry.AspNetCore/ApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Microsoft.AspNetCore.Hosting;
#if NETSTANDARD2_0
using IHostApplicationLifetime = Microsoft.AspNetCore.Hosting.IApplicationLifetime;
#else
using Microsoft.Extensions.Hosting;
#endif
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand All @@ -11,7 +15,6 @@
using Sentry.Extensions.Logging;
using Sentry.Infrastructure;


// ReSharper disable once CheckNamespace -- Discoverability
namespace Microsoft.AspNetCore.Builder
{
Expand Down Expand Up @@ -55,7 +58,7 @@ public static IApplicationBuilder UseSentry(this IApplicationBuilder app)
}
}

var lifetime = app.ApplicationServices.GetService<IApplicationLifetime>();
var lifetime = app.ApplicationServices.GetService<IHostApplicationLifetime>();
lifetime?.ApplicationStopped.Register(SentrySdk.Close);

return app.UseMiddleware<SentryMiddleware>();
Expand Down
8 changes: 6 additions & 2 deletions src/Sentry.AspNetCore/Sentry.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netcoreapp3.0;netstandard2.0</TargetFrameworks>
<PackageTags>$(PackageTags);AspNetCore;MVC</PackageTags>
<PackageId>Sentry.AspNetCore</PackageId>
<AssemblyName>Sentry.AspNetCore</AssemblyName>
Expand All @@ -13,12 +13,16 @@
<ProjectReference Include="..\Sentry.Extensions.Logging\Sentry.Extensions.Logging.csproj" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.Abstractions" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.1.0" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

</Project>
6 changes: 5 additions & 1 deletion src/Sentry.AspNetCore/SentryAspNetCoreOptionsSetup.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Logging.Configuration;
using Microsoft.Extensions.Options;
using Sentry.Extensions.Logging;
using Sentry.Internal;
#if NETSTANDARD2_0
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#else
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IWebHostEnvironment;
#endif

namespace Sentry.AspNetCore
{
Expand Down
6 changes: 5 additions & 1 deletion src/Sentry.AspNetCore/SentryMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
using System.Runtime.ExceptionServices;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Hosting;
#if NETSTANDARD2_0
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#else
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IWebHostEnvironment;
#endif
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>netcoreapp3.0;netstandard2.0</TargetFrameworks>
<PackageTags>$(PackageTags);Logging;Microsoft.Extensions.Logging</PackageTags>
<PackageId>Sentry.Extensions.Logging</PackageId>
<AssemblyName>Sentry.Extensions.Logging</AssemblyName>
Expand All @@ -13,8 +13,12 @@
<ProjectReference Include="../../src/Sentry/Sentry.csproj" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="2.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Configuration" Version="3.0.0" />
</ItemGroup>

</Project>
5 changes: 2 additions & 3 deletions src/Sentry/Internal/AppDomainAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,13 @@ private AppDomainAdapter()
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
AppDomain.CurrentDomain.ProcessExit += OnProcessExit;
}

public event UnhandledExceptionEventHandler UnhandledException;

public event EventHandler ProcessExit;

private void OnProcessExit(object sender, EventArgs e) => ProcessExit?.Invoke(sender, e);

private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
=> UnhandledException?.Invoke(this, e);
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) => UnhandledException?.Invoke(this, e);
}
}
6 changes: 5 additions & 1 deletion test/Sentry.AspNetCore.Tests/MiddlewareLoggerIntegration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
#if NETCOREAPP2_1 || NET461
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#else
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IWebHostEnvironment;
#endif
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Logging;
Expand Down
5 changes: 2 additions & 3 deletions test/Sentry.AspNetCore.Tests/Sentry.AspNetCore.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>

<!-- Running these tests on Mono just hangs -->
Expand All @@ -14,13 +14,12 @@
<ProjectReference Include="../Sentry.Testing/Sentry.Testing.csproj" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' OR '$(TargetFramework)' == 'net461'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.2" />
</ItemGroup>


<ItemGroup>
<None Update="*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using System;
using Microsoft.AspNetCore.Hosting;
#if NETCOREAPP2_1 || NET461
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#else
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IWebHostEnvironment;
#endif
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Configuration;
using NSubstitute;
Expand Down
6 changes: 5 additions & 1 deletion test/Sentry.AspNetCore.Tests/SentryMiddlewareTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Diagnostics;
#if NETCOREAPP2_1 || NET461
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#else
using Microsoft.AspNetCore.Hosting;
#endif
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Logging;
Expand All @@ -22,7 +26,7 @@ private class Fixture
public IHub Hub { get; set; } = Substitute.For<IHub>();
public Func<IHub> HubAccessor { get; set; }
public SentryAspNetCoreOptions Options { get; set; } = new SentryAspNetCoreOptions();
public IHostingEnvironment HostingEnvironment { get; set; } = Substitute.For<IHostingEnvironment>();
public IWebHostEnvironment HostingEnvironment { get; set; } = Substitute.For<IWebHostEnvironment>();
public ILogger<SentryMiddleware> Logger { get; set; } = Substitute.For<ILogger<SentryMiddleware>>();
public HttpContext HttpContext { get; set; } = Substitute.For<HttpContext>();
public IFeatureCollection FeatureCollection { get; set; } = Substitute.For<IFeatureCollection>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
using System;
using System.Collections.Generic;
#if NETCOREAPP2_1 || NET461
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#else
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IWebHostEnvironment;
#endif
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down
7 changes: 6 additions & 1 deletion test/Sentry.AspNetCore.Tests/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
#if NETCOREAPP2_1 || NET461
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
#else
using IHostingEnvironment = Microsoft.AspNetCore.Hosting.IWebHostEnvironment;
#endif
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

Expand All @@ -20,6 +24,7 @@ public void ConfigureServices(IServiceCollection services)

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{

}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Internal;
using NSubstitute;
using Sentry.Protocol;
using Xunit;
Expand Down Expand Up @@ -43,6 +42,9 @@ public void LogLevel_HigherLevel_IsEnabled()
Assert.False(sut.IsEnabled(SentryLevel.Info));
}

// .NET Core 3 has turned FormattedLogValues into an internal readonly struct
// and now we can't match that with NSubstitute
#if !NETCOREAPP3_1
[Fact]
public void Log_PassedThrough()
{
Expand All @@ -59,9 +61,10 @@ public void Log_PassedThrough()
_fixture.MelLogger.Received(1).Log<object>(
expectedLevel.ToMicrosoft(),
0,
Arg.Is<FormattedLogValues>(e => e.ToString() == expectedMessage),
Arg.Is<object>(e => e.ToString() == expectedMessage),
expectedException,
Arg.Any<Func<object, Exception, string>>());
}
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1' OR '$(TargetFramework)' == 'net461'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../src/Sentry.Extensions.Logging/Sentry.Extensions.Logging.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Sentry.Log4Net.Tests/Sentry.Log4Net.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Sentry.NLog.Tests/Sentry.NLog.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.NLog\Sentry.NLog.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion test/Sentry.Serilog.Tests/Sentry.Serilog.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 6 additions & 3 deletions test/Sentry.Testing/Sentry.Testing.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;net461</TargetFrameworks>
<IsTestProject>false</IsTestProject>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../../src/Sentry/Sentry.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.2.0" />
<ItemGroup Condition="$(TargetFramework) == 'netcoreapp2.1' OR $(TargetFramework) == 'net461'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.1.1" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion test/Sentry.Tests/Sentry.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 598ab4f

Please sign in to comment.