Skip to content

Commit

Permalink
Integrate GenericHost and refine namespaces (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
glucaci committed Jan 23, 2019
1 parent 54328a2 commit 7337d17
Show file tree
Hide file tree
Showing 90 changed files with 675 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Thor.AspNetCore.FunctionalTest</AssemblyName>
<RootNamespace>Thor.AspNetCore.FunctionalTest</RootNamespace>
<AssemblyName>Thor.Hosting.AspNetCore.FunctionalTest</AssemblyName>
<RootNamespace>Thor.Hosting.AspNetCore.FunctionalTest</RootNamespace>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;

namespace Thor.AspNetCore.FunctionalTest.Controllers
namespace Thor.Hosting.AspNetCore.FunctionalTest.Controllers
{
[Route("api/[controller]")]
public class ValuesController : Controller
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/AspNetCore.FunctionalTest/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;

namespace Thor.AspNetCore.FunctionalTest
namespace Thor.Hosting.AspNetCore.FunctionalTest
{
public class Program
{
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/AspNetCore.FunctionalTest/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Thor.AspNetCore.FunctionalTest
namespace Thor.Hosting.AspNetCore.FunctionalTest
{
public class Startup
{
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/AspNetCore.Tests/AspNetCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>Thor.AspNetCore.Tests</AssemblyName>
<RootNamespace>Thor.AspNetCore.Tests</RootNamespace>
<AssemblyName>Thor.Hosting.AspNetCore.Tests</AssemblyName>
<RootNamespace>Thor.Hosting.AspNetCore.Tests</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Security.Claims;
using Xunit;

namespace Thor.AspNetCore.Tests
namespace Thor.Hosting.AspNetCore.Tests
{
public class ClaimsPrincipalExtensionsTests
{
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/AspNetCore.Tests/HttpRequestExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Thor.Core.Abstractions;
using Xunit;

namespace Thor.AspNetCore.Tests
namespace Thor.Hosting.AspNetCore.Tests
{
public class HttpRequestExtensionsTests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Moq;
using Xunit;

namespace Thor.AspNetCore.Tests
namespace Thor.Hosting.AspNetCore.Tests
{
public class ServiceCollectionExtensionsTests
{
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/AspNetCore.Tests/TestServerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.TestHost;

namespace Thor.AspNetCore.Tests
namespace Thor.Hosting.AspNetCore.Tests
{
public class TestServerContext
: IDisposable
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/AspNetCore.Tests/TestServerStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace Thor.AspNetCore.Tests
namespace Thor.Hosting.AspNetCore.Tests
{
public class TestServerStartup
{
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/AspNetCore/AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<PackageId>Thor.AspNetCore</PackageId>
<AssemblyName>Thor.AspNetCore</AssemblyName>
<RootNamespace>Thor.AspNetCore</RootNamespace>
<AssemblyName>Thor.Hosting.AspNetCore</AssemblyName>
<RootNamespace>Thor.Hosting.AspNetCore</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Description>Provides tracing capabilities for AspNet core 2.0 and higher.</Description>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/AspNetCore/AssemblyAttributes.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Thor.AspNetCore.Tests")]
[assembly: InternalsVisibleTo("Thor.Hosting.AspNetCore.Tests")]
2 changes: 1 addition & 1 deletion src/Clients/AspNetCore/ClaimsPrincipalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Security.Claims;

namespace Thor.AspNetCore
namespace Thor.Hosting.AspNetCore
{
internal static class ClaimsPrincipalExtensions
{
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/AspNetCore/HostingDiagnosticsListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.Extensions.DiagnosticAdapter;
using Thor.Core.Abstractions;
using Thor.Core.Http;
using Thor.Extensions.Http;

namespace Thor.AspNetCore
namespace Thor.Hosting.AspNetCore
{
internal class HostingDiagnosticsListener
: IDiagnosticsListener
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/AspNetCore/HttpRequestExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.Extensions.Primitives;
using Thor.Core.Abstractions;

namespace Thor.AspNetCore
namespace Thor.Hosting.AspNetCore
{
internal static class HttpRequestExtensions
{
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/AspNetCore/JwtClaimNames.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Thor.AspNetCore
namespace Thor.Hosting.AspNetCore
{
internal static class JwtClaimNames
{
Expand Down
4 changes: 2 additions & 2 deletions src/Clients/AspNetCore/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
using Microsoft.Extensions.DependencyInjection;
using Thor.Core;
using Thor.Core.Abstractions;
using Thor.Core.Http;
using Thor.Core.Session;
using Thor.Core.Transmission.BlobStorage;
using Thor.Core.Transmission.EventHub;
using Thor.Extensions.Http;

namespace Thor.AspNetCore
namespace Thor.Hosting.AspNetCore
{
/// <summary>
/// A bunch of convenient extensions methods for <see cref="IServiceCollection"/>.
Expand Down
2 changes: 1 addition & 1 deletion src/Clients/AspNetCore/TracingStartupFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Thor.Core.Session.Abstractions;
using Thor.Core.Transmission.Abstractions;

namespace Thor.AspNetCore
namespace Thor.Hosting.AspNetCore
{
/// <summary>
/// A <see cref="IStartupFilter"/> to initialize tracing.
Expand Down
55 changes: 50 additions & 5 deletions src/Clients/Clients.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore.Tests", "AspNetC
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNetCore.FunctionalTest", "AspNetCore.FunctionalTest\AspNetCore.FunctionalTest.csproj", "{9F68F53A-5B42-427C-A3C7-65E55BFECD65}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AspNetCore", "AspNetCore", "{70E291CF-2741-4A9C-A651-864D74519D31}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Hosting", "Hosting", "{70E291CF-2741-4A9C-A651-864D74519D31}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HotChocolate", "HotChocolate", "{F2AA2E9C-4E3B-4476-8CA4-711EAC8C5B51}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Extensions", "Extensions", "{F2AA2E9C-4E3B-4476-8CA4-711EAC8C5B51}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Http", "Http\Http.csproj", "{FE08EE64-3829-4EF7-881E-7C1F644A84C8}"
EndProject
Expand Down Expand Up @@ -40,6 +40,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Transmission.BlobStorage",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Transmission.EventHub", "..\Core\Transmission.EventHub\Transmission.EventHub.csproj", "{D6C08350-32F2-4EA9-8C87-85FE7B74272F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenericHost", "GenericHost\GenericHost.csproj", "{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenericHost.Sample", "GenericHost.Sample\GenericHost.Sample.csproj", "{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenericHost.Tests", "GenericHost.Tests\GenericHost.Tests.csproj", "{04737B2C-EF2D-4109-870B-A4B60865C3E7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -240,6 +246,42 @@ Global
{D6C08350-32F2-4EA9-8C87-85FE7B74272F}.Release|x64.Build.0 = Release|Any CPU
{D6C08350-32F2-4EA9-8C87-85FE7B74272F}.Release|x86.ActiveCfg = Release|Any CPU
{D6C08350-32F2-4EA9-8C87-85FE7B74272F}.Release|x86.Build.0 = Release|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Debug|x64.ActiveCfg = Debug|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Debug|x64.Build.0 = Debug|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Debug|x86.ActiveCfg = Debug|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Debug|x86.Build.0 = Debug|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Release|Any CPU.Build.0 = Release|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Release|x64.ActiveCfg = Release|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Release|x64.Build.0 = Release|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Release|x86.ActiveCfg = Release|Any CPU
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95}.Release|x86.Build.0 = Release|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Debug|x64.ActiveCfg = Debug|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Debug|x64.Build.0 = Debug|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Debug|x86.ActiveCfg = Debug|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Debug|x86.Build.0 = Debug|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Release|Any CPU.Build.0 = Release|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Release|x64.ActiveCfg = Release|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Release|x64.Build.0 = Release|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Release|x86.ActiveCfg = Release|Any CPU
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173}.Release|x86.Build.0 = Release|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Debug|x64.ActiveCfg = Debug|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Debug|x64.Build.0 = Debug|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Debug|x86.ActiveCfg = Debug|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Debug|x86.Build.0 = Debug|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Release|Any CPU.Build.0 = Release|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Release|x64.ActiveCfg = Release|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Release|x64.Build.0 = Release|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Release|x86.ActiveCfg = Release|Any CPU
{04737B2C-EF2D-4109-870B-A4B60865C3E7}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -248,9 +290,9 @@ Global
{244FBD9C-1AC1-4769-A549-5E753014D731} = {70E291CF-2741-4A9C-A651-864D74519D31}
{4EEFBF73-277E-40D6-872F-ADFF3ACF71CA} = {70E291CF-2741-4A9C-A651-864D74519D31}
{9F68F53A-5B42-427C-A3C7-65E55BFECD65} = {70E291CF-2741-4A9C-A651-864D74519D31}
{FE08EE64-3829-4EF7-881E-7C1F644A84C8} = {70E291CF-2741-4A9C-A651-864D74519D31}
{7431E6B8-32F2-4D6A-8634-E2D54942E88A} = {70E291CF-2741-4A9C-A651-864D74519D31}
{1380BD48-8FF4-4F5A-AA5C-B4D95B8855C3} = {70E291CF-2741-4A9C-A651-864D74519D31}
{FE08EE64-3829-4EF7-881E-7C1F644A84C8} = {F2AA2E9C-4E3B-4476-8CA4-711EAC8C5B51}
{7431E6B8-32F2-4D6A-8634-E2D54942E88A} = {F2AA2E9C-4E3B-4476-8CA4-711EAC8C5B51}
{1380BD48-8FF4-4F5A-AA5C-B4D95B8855C3} = {F2AA2E9C-4E3B-4476-8CA4-711EAC8C5B51}
{AC464A95-3C51-4226-945C-3C7C8C4EBE0A} = {F2AA2E9C-4E3B-4476-8CA4-711EAC8C5B51}
{2701B377-9A35-4FB9-B372-989B9C9B29B9} = {F2AA2E9C-4E3B-4476-8CA4-711EAC8C5B51}
{09286726-BA8E-405D-9419-758D3359101C} = {F2AA2E9C-4E3B-4476-8CA4-711EAC8C5B51}
Expand All @@ -261,6 +303,9 @@ Global
{2DFF97A1-F302-4E68-8998-18026DD081B0} = {7754286E-741D-4F25-9812-CC9556752820}
{EAF1869D-9FAD-40BA-86D4-3FE71B4DD41D} = {7754286E-741D-4F25-9812-CC9556752820}
{D6C08350-32F2-4EA9-8C87-85FE7B74272F} = {7754286E-741D-4F25-9812-CC9556752820}
{4A312E09-ABA1-451B-A4C8-2C5E6359AA95} = {70E291CF-2741-4A9C-A651-864D74519D31}
{54BA98E5-1C8D-427F-BDF7-2D29BE5CD173} = {70E291CF-2741-4A9C-A651-864D74519D31}
{04737B2C-EF2D-4109-870B-A4B60865C3E7} = {70E291CF-2741-4A9C-A651-864D74519D31}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6519AA7A-DDB1-4DFD-9EC9-570B8C63E25E}
Expand Down
19 changes: 19 additions & 0 deletions src/Clients/GenericHost.Sample/GenericHost.Sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Thor.Hosting.GenericHost.FunctionalTest</AssemblyName>
<RootNamespace>Thor.Hosting.GenericHost.FunctionalTest</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GenericHost\GenericHost.csproj" />
</ItemGroup>

</Project>
14 changes: 14 additions & 0 deletions src/Clients/GenericHost.Sample/MyBackgroundService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Threading;
using System.Threading.Tasks;

namespace Thor.Hosting.GenericHost.FunctionalTest
{
internal class MyBackgroundService : BackgroundServiceBase
{
protected override Task OnExecuteAsync(CancellationToken stoppingToken)
{
// Do some work
return Task.CompletedTask;
}
}
}
22 changes: 22 additions & 0 deletions src/Clients/GenericHost.Sample/MyHostedService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Threading;
using System.Threading.Tasks;

namespace Thor.Hosting.GenericHost.FunctionalTest
{
internal class MyHostedService : HostedServiceBase
{
protected override Task OnStartAsync(
CancellationToken cancellationToken)
{
// Start some work
return Task.CompletedTask;
}

protected override Task OnStopAsync(
CancellationToken cancellationToken)
{
// Stop the work
return Task.CompletedTask;
}
}
}
33 changes: 33 additions & 0 deletions src/Clients/GenericHost.Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System.Collections.Generic;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Thor.Hosting.GenericHost.FunctionalTest
{
public static class Program
{
static void Main(string[] args)
{
Dictionary<string, string> configuration =
new Dictionary<string, string>
{
{"Tracing:ApplicationId", "999"},
{"Tracing:Level", "Verbose"},
{"Tracing:BlobStorage:ConnectionString", "***"},
{"Tracing:BlobStorage:AttachmentContainerName", "demo"},
{"Tracing:EventHub:ConnectionString", "***"}
};

new HostBuilder()
.ConfigureHostConfiguration(builder =>
builder.AddInMemoryCollection(configuration))
.ConfigureServices(services =>
{
services.AddHostedService<MyHostedService>();
services.AddHostedService<MyBackgroundService>();
})
.RunWithTracing();
}
}
}
Loading

0 comments on commit 7337d17

Please sign in to comment.