This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<ServiceDefinition name="AzureCloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6"> | |
<WorkerRole name="WorkerRole" vmsize="Standard_D1_v2"> | |
<ConfigurationSettings> | |
<Setting name="foo" /> | |
</ConfigurationSettings> | |
<Runtime executionContext="limited"> | |
<EntryPoint> | |
<ProgramEntryPoint commandLine="NetCoreConsoleApp.exe" setReadyOnProcessStart="true" /> | |
</EntryPoint> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true -o bin/publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.WindowsAzure.ServiceRuntime.Internal; | |
using System; | |
using System.Diagnostics; | |
using System.Threading; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class StartupWithEmptyContentTypeFormatter | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
_ = services ?? throw new ArgumentNullException(nameof(services)); | |
services | |
.AddMvc(o => { o.AddEmptyContentTypeFormatter(); }) | |
.WithController<TestController>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class MvcApplicationPartManagerExtensions | |
{ | |
public static IMvcBuilder WithController<T>(this IMvcBuilder builder) | |
{ | |
return builder.ConfigureApplicationPartManager(m => | |
{ | |
m.FeatureProviders.Add(new CustomControllerFeatureProvider(typeof(T).GetTypeInfo())); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Microsoft.AspNetCore.Mvc.Controllers | |
{ | |
/// <summary> | |
/// Discovers controllers from a list of <see cref="ApplicationPart"/> instances. | |
/// </summary> | |
public class ControllerFeatureProvider : IApplicationFeatureProvider<ControllerFeature> | |
{ | |
// .... | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public async Task Controller_ShouldReturn200WithJsonOutput_IfNoContentTypeIsProvided() | |
{ | |
// arrange | |
var builder = new WebHostBuilder() | |
.UseStartup<StartupWithEmptyContentTypeFormatter>(); | |
var server = new TestServer(builder); | |
var client = server.CreateClient(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class TestController : Controller | |
{ | |
[HttpPost("/200")] | |
public IActionResult HandlePost200([FromBody]InputRequestData data) | |
{ | |
return Json(data); | |
} | |
} | |
private class InputRequestData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private class StartupWithEmptyContentTypeFormatter | |
{ | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
_ = services ?? throw new ArgumentNullException(nameof(services)); | |
services | |
.AddMvc(o => { o.AddEmptyContentTypeFormatter(); }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EmptyContentTypeJsonInputFormatter : InputFormatter | |
{ | |
private readonly JsonInputFormatter _inner; | |
public EmptyContentTypeJsonInputFormatter(JsonInputFormatter inner) | |
{ | |
_inner = inner ?? throw new ArgumentNullException(nameof(inner)); | |
} | |
public override bool CanRead(InputFormatterContext context) |