diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp.csproj b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp.csproj index 41090f89c37db..0364131b1635b 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp.csproj +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp.csproj @@ -1,4 +1,4 @@ - + @@ -12,7 +12,9 @@ + + diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/Program.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/ProgramNet461Compat.cs similarity index 90% rename from sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/Program.cs rename to sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/ProgramNet461Compat.cs index 2fee18838a744..005e6db6978ec 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/Program.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/ProgramNet461Compat.cs @@ -1,15 +1,17 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +#if NET461 using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; namespace Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp { - public class Program + public partial class Program { public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run(); public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args).UseStartup(); } } +#endif diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/ProgramNetCoreAppCompat.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/ProgramNetCoreAppCompat.cs new file mode 100644 index 0000000000000..6aa42d5610a32 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/ProgramNetCoreAppCompat.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#if NETCOREAPP +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp +{ + public partial class Program + { + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); + } +} +#endif diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/Startup.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/StartupNet461Compat.cs similarity index 96% rename from sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/Startup.cs rename to sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/StartupNet461Compat.cs index 3f9168cf3b506..0d39ac1a87839 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/Startup.cs +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/StartupNet461Compat.cs @@ -1,6 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. - +#if NET461 using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; @@ -9,7 +9,7 @@ namespace Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp { - public class Startup + public partial class Startup { public Startup(IConfiguration configuration) { @@ -48,3 +48,4 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) } } } +#endif diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/StartupNetCoreAppCompat.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/StartupNetCoreAppCompat.cs new file mode 100644 index 0000000000000..fd29d2cbd1b24 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests.AspNetCoreWebApp/StartupNetCoreAppCompat.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +#if NETCOREAPP +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp +{ + public partial class Startup + { + public Startup(IConfiguration configuration) + { + this.Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddControllers(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseRouting(); + + app.UseAuthorization(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + } + } +} +#endif diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests/Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.csproj b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests/Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.csproj index daece04443f43..c0043d01f6962 100644 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests/Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.csproj +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/tests/Integration.Tests/Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.csproj @@ -5,7 +5,6 @@ - @@ -18,20 +17,25 @@ - - - + + + + + + + + + +