Skip to content

Commit

Permalink
Fix module init issue with Verify (#2092)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjohnsonpint authored Dec 19, 2022
1 parent ef9a7cc commit 9840ccb
Show file tree
Hide file tree
Showing 26 changed files with 95 additions and 25 deletions.
7 changes: 7 additions & 0 deletions Sentry.sln
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Bindings.Android", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.Bindings.Cocoa", "src\Sentry.Bindings.Cocoa\Sentry.Bindings.Cocoa.csproj", "{F533FD6D-1E10-4F06-BE3A-3B3C713A75A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sentry.AspNetCore.TestUtils", "test\Sentry.AspNetCore.TestUtils\Sentry.AspNetCore.TestUtils.csproj", "{C96CB65D-3D2D-404E-85C0-69A3FC03B48F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -397,6 +399,10 @@ Global
{F533FD6D-1E10-4F06-BE3A-3B3C713A75A6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F533FD6D-1E10-4F06-BE3A-3B3C713A75A6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F533FD6D-1E10-4F06-BE3A-3B3C713A75A6}.Release|Any CPU.Build.0 = Release|Any CPU
{C96CB65D-3D2D-404E-85C0-69A3FC03B48F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C96CB65D-3D2D-404E-85C0-69A3FC03B48F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C96CB65D-3D2D-404E-85C0-69A3FC03B48F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C96CB65D-3D2D-404E-85C0-69A3FC03B48F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -460,6 +466,7 @@ Global
{70066C6C-0A18-4322-A02A-9A0DFE59C02B} = {77454495-55EE-4B40-A089-71B9E8F82E89}
{9A23DA57-3F0B-4646-A37A-71A4CE7C94CB} = {AF6AF4C7-8AA2-4D59-8064-2D79560904EB}
{F533FD6D-1E10-4F06-BE3A-3B3C713A75A6} = {AF6AF4C7-8AA2-4D59-8064-2D79560904EB}
{C96CB65D-3D2D-404E-85C0-69A3FC03B48F} = {83263231-1A2A-4733-B759-EEFF14E8C5D5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0C652B1A-DF72-4EE5-A98B-194FE2C054F6}
Expand Down
15 changes: 9 additions & 6 deletions SentryAspNetCore.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@
"solution": {
"path": "Sentry.sln",
"projects": [
"src\\Sentry\\Sentry.csproj",
"src\\Sentry.AspNetCore\\Sentry.AspNetCore.csproj",
"src\\Sentry.AspNetCore.Grpc\\Sentry.AspNetCore.Grpc.csproj",
"src\\Sentry.AspNetCore\\Sentry.AspNetCore.csproj",
"src\\Sentry.Extensions.Logging\\Sentry.Extensions.Logging.csproj",
"test\\Sentry.Testing\\Sentry.Testing.csproj",
"test\\Sentry.Tests\\Sentry.Tests.csproj",
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
"src\\Sentry\\Sentry.csproj",
"test\\Sentry.AspNetCore.Grpc.Tests\\Sentry.AspNetCore.Grpc.Tests.csproj",
"test\\Sentry.AspNetCore.Tests\\Sentry.AspNetCore.Tests.csproj",
"test\\Sentry.AspNetCore.TestUtils\\Sentry.AspNetCore.TestUtils.csproj",
"test\\Sentry.Extensions.Logging.Tests\\Sentry.Extensions.Logging.Tests.csproj",
"test\\Sentry.Google.Cloud.Functions.Tests\\Sentry.Google.Cloud.Functions.Tests.csproj",
"test\\Sentry.Serilog.Tests\\Sentry.Serilog.Tests.csproj",
"test\\Sentry.Testing\\Sentry.Testing.csproj",
"test\\Sentry.Tests\\Sentry.Tests.csproj"
]
}
}
}
1 change: 1 addition & 0 deletions src/Sentry/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[assembly: InternalsVisibleTo("Sentry.AspNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNet.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNetCore.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNetCore.TestUtils, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNetCore, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNetCore.Grpc, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
[assembly: InternalsVisibleTo("Sentry.AspNetCore.Grpc.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010059964a931488bcdbd14657f1ee0df32df61b57b3d14d7290c262c2cc9ddaad6ec984044f761f778e1823049d2cb996a4f58c8ea5b46c37891414cb34b4036b1c178d7b582289d2eef3c0f1e9b692c229a306831ee3d371d9e883f0eb0f74aeac6c6ab8c85fd1ec04b267e15a31532c4b4e2191f5980459db4dce0081f1050fb8")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#if !__MOBILE__
public static class ModuleInit
public static class CommonModuleInit
{
[ModuleInitializer]
public static void Init() =>
Expand Down
5 changes: 5 additions & 0 deletions test/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
<Compile Remove="**\*.verify.cs" />
</ItemGroup>

<!-- common module init for all test projects -->
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<Compile Include="$(MSBuildThisFileDirectory)CommonModuleInit.cs" />
</ItemGroup>

<!-- configure xunit -->
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
<Content Include="..\xunit.runner.windows.json" Condition="$([MSBuild]::IsOSPlatform('windows'))">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.AspNetCore.Grpc\Sentry.AspNetCore.Grpc.csproj" />
<ProjectReference Include="..\Sentry.AspNetCore.Tests\Sentry.AspNetCore.Tests.csproj" />
<ProjectReference Include="..\Sentry.AspNetCore.TestUtils\Sentry.AspNetCore.TestUtils.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Grpc.Net.Client;
using Microsoft.AspNetCore.Hosting;
using Sentry.AspNetCore.Tests;
using Sentry.AspNetCore.TestUtils;

namespace Sentry.AspNetCore.Grpc.Tests;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Hosting;
using Sentry.AspNetCore.Tests.Utils;

namespace Sentry.AspNetCore.Tests;
namespace Sentry.AspNetCore.TestUtils;

// Allows integration tests the include the background worker and mock only the HTTP bits
public class AspNetSentrySdkTestFixture : SentrySdkTestFixture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Microsoft.Extensions.DependencyInjection;

namespace Sentry.AspNetCore.Tests.Utils.Extensions;
namespace Sentry.AspNetCore.TestUtils;

internal static class DependencyContainerExtensions
public static class DependencyContainerExtensions
{
public static void EnableValidation(this ServiceProviderOptions options, bool enable = true)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.TestHost;
using Sentry.AspNetCore.Tests.Utils.Extensions;

namespace Sentry.AspNetCore.Tests.Utils;
namespace Sentry.AspNetCore.TestUtils;

internal static class FakeSentryServer
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;

namespace Sentry.AspNetCore.Tests;
namespace Sentry.AspNetCore.TestUtils;

public class LastExceptionFilter : IStartupFilter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Http;

namespace Sentry.AspNetCore.Tests;
namespace Sentry.AspNetCore.TestUtils;

public class RequestHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1;net48</TargetFrameworks>
<IsTestProject>false</IsTestProject>
</PropertyGroup>

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

<ItemGroup Condition="$(TargetFramework) == 'net48'">
<PackageReference Include="Microsoft.AspNetCore" Version="2.*" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.*" />

<!-- this is needed because the version that is brought in transitively has a vulnerability warning -->
<PackageReference Include="Microsoft.AspNetCore.Server.IIS" Version="2.*" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.*" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.*" />
<PackageReference Include="Verify.AspNetCore" Version="2.*" />
<PackageReference Include="Verify.Http" Version="4.*" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework) == 'net7.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.*" />
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="7.*" />
<PackageReference Include="Verify.AspNetCore" Version="3.*" />
<PackageReference Include="Verify.Http" Version="4.*" />
</ItemGroup>

<ItemGroup>
<None Update="*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;

namespace Sentry.AspNetCore.Tests;
namespace Sentry.AspNetCore.TestUtils;

public abstract class SentrySdkTestFixture : IDisposable
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Sentry.AspNetCore.TestUtils;

namespace Sentry.AspNetCore.Tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.Options;
using Sentry.AspNetCore;
using Sentry.AspNetCore.Tests;
using Sentry.AspNetCore.TestUtils;
using Sentry.Extensions.Logging;

// ReSharper disable once CheckNamespace - To test Logger emitting events:
Expand Down
1 change: 1 addition & 0 deletions test/Sentry.AspNetCore.Tests/IntegrationsTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Sentry.AspNetCore.TestUtils;

namespace Sentry.AspNetCore.Tests;

Expand Down
6 changes: 5 additions & 1 deletion test/Sentry.AspNetCore.Tests/ModuleInit.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#if NET6_0_OR_GREATER
namespace Sentry.AspNetCore.Tests;

public static class ModuleInit
{
[ModuleInitializer]
public static void Init() =>
public static void Init()
{
VerifyHttp.Enable();
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.AspNetCore\Sentry.AspNetCore.csproj" />
<ProjectReference Include="..\Sentry.AspNetCore.TestUtils\Sentry.AspNetCore.TestUtils.csproj" />
<ProjectReference Include="..\Sentry.Testing\Sentry.Testing.csproj" />
</ItemGroup>

Expand Down
2 changes: 2 additions & 0 deletions test/Sentry.AspNetCore.Tests/SentryCoreDependentCollection.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Sentry.AspNetCore.TestUtils;

namespace Sentry.AspNetCore.Tests;

[CollectionDefinition(nameof(AspNetSentrySdkTestFixture))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Http;
using Sentry.AspNetCore.Tests.Utils.Extensions;
using Sentry.AspNetCore.TestUtils;

namespace Sentry.AspNetCore.Tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Sentry.AspNetCore.Tests.Utils.Extensions;
using Sentry.AspNetCore.TestUtils;

namespace Sentry.AspNetCore.Tests;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.Google.Cloud.Functions\Sentry.Google.Cloud.Functions.csproj" />
<ProjectReference Include="..\Sentry.AspNetCore.Tests\Sentry.AspNetCore.Tests.csproj" />
<ProjectReference Include="..\Sentry.AspNetCore.TestUtils\Sentry.AspNetCore.TestUtils.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion test/Sentry.Serilog.Tests/AspNetCoreIntegrationTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sentry.AspNetCore.Tests;
using Sentry.AspNetCore.TestUtils;

namespace Sentry.Serilog.Tests;

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
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="Serilog.Extensions.Logging" Version="3.*" />

<ProjectReference Include="..\..\src\Sentry.Serilog\Sentry.Serilog.csproj" />
<ProjectReference Include="..\Sentry.AspNetCore.Tests\Sentry.AspNetCore.Tests.csproj" />
<ProjectReference Include="..\Sentry.AspNetCore.TestUtils\Sentry.AspNetCore.TestUtils.csproj" />

<Using Include="System.Collections" />
<Using Include="System.IO.Compression" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Sentry.AspNetCore.Tests;
using Sentry.AspNetCore.TestUtils;

namespace Sentry.Serilog.Tests;

Expand Down

0 comments on commit 9840ccb

Please sign in to comment.