Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<!-- Lots of our dependencies are not strong-named -->
<NoWarn>$(NoWarn);8002</NoWarn>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
<LangVersion>10.0</LangVersion>
</PropertyGroup>

<Import Project="$(RepoRoot)test\Test.Infrastructure\Microsoft.AspNetCore.Testing.props" Condition=" '$(IsTestProject)' == 'true' " />
Expand Down
2 changes: 1 addition & 1 deletion eng/common/dotnet-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ done
# Use uname to determine what the CPU is, see https://en.wikipedia.org/wiki/Uname#Examples
cpuname=$(uname -m)
case $cpuname in
aarch64)
aarch64|arm64)
buildarch=arm64
;;
amd64|x86_64)
Expand Down
2 changes: 1 addition & 1 deletion eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ function InitializeBuildTool() {
ExitWithExitCode 1
}
$dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName 'dotnet')
$buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'netcoreapp3.1' }
$buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'net6.0' }
} elseif ($msbuildEngine -eq "vs") {
try {
$msbuildPath = InitializeVisualStudioMSBuild -install:$restore
Expand Down
2 changes: 1 addition & 1 deletion eng/common/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ function InitializeBuildTool {
# return values
_InitializeBuildTool="$_InitializeDotNetCli/dotnet"
_InitializeBuildToolCommand="msbuild"
_InitializeBuildToolFramework="netcoreapp3.1"
_InitializeBuildToolFramework="net6.0"
}

# Set RestoreNoCache as a workaround for https://github.com/NuGet/Home/issues/3116
Expand Down
6 changes: 3 additions & 3 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"tools": {
"dotnet": "6.0.100-preview.6.21355.2",
"dotnet": "6.0.100-rc.2.21505.57",
"runtimes": {
"dotnet": [
"3.1.14"
"6.0.0-rc.2.21480.5"
],
"aspnetcore": [
"3.1.14"
"6.0.0-rc.2.21480.10"
]
}
},
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.Tye.Core/ConfigModel/ConfigApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ public void Validate()
foreach (var probe in probes)
{
context = new ValidationContext(probe.Probe!);
if (!Validator.TryValidateObject(probe.Probe, context, results, validateAllProperties: true))
// TODO: Investigate possible null.
if (!Validator.TryValidateObject(probe.Probe!, context, results, validateAllProperties: true))
{
throw new TyeYamlException(
$"Probe '{probe.Name}' in service '{service.Name}' validation failed." + Environment.NewLine +
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Tye.Core/Microsoft.Tye.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Tye</RootNamespace>
<AssemblyName>Microsoft.Tye.Core</AssemblyName>
<PackageId>Microsoft.Tye.Core</PackageId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Description>Diagnostics collector and exporter for .NET Core applications.</Description>
<AssemblyName>Microsoft.Tye.Hosting.Diagnostics</AssemblyName>
<PackageId>Microsoft.Tye.Hosting.Diagnostics</PackageId>
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Tye.Hosting/DockerRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ service.Description.RunInfo is IngressRunInfo ||

// Inject a proxy per non-container service. This allows the container to use normal host names within the
// container network to talk to services on the host
var proxyContainer = new DockerRunInfo($"mcr.microsoft.com/dotnet/core/sdk:3.1", "dotnet Microsoft.Tye.Proxy.dll")
var proxyContainer = new DockerRunInfo($"mcr.microsoft.com/dotnet/sdk:6.0", "dotnet Microsoft.Tye.Proxy.dll")
{
WorkingDirectory = "/app",
NetworkAlias = service.Description.Name,
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.Tye.Hosting/HttpProxyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ public async Task StartAsync(Application application)
}
var uri = new UriBuilder(uris[next].Uri)
{
Path = rule.PreservePath ? $"{context.Request.Path}" : (string)context.Request.RouteValues["path"] ?? "/",
// TODO: Investigate possible null.
Path = rule.PreservePath ? $"{context.Request.Path}" : (string)context.Request!.RouteValues["path"]! ?? "/",
Query = context.Request.QueryString.Value
};

Expand Down
6 changes: 4 additions & 2 deletions src/Microsoft.Tye.Hosting/Infrastructure/ProxyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public static HttpRequestMessage CreateProxyHttpRequest(this HttpContext context

// Append request forwarding headers
requestMessage.Headers.TryAddWithoutValidation("Via", $"{context.Request.Protocol} Tye");
requestMessage.Headers.TryAddWithoutValidation("X-Forwarded-For", context.Connection.RemoteIpAddress.ToString());
// TODO: Investigate possible null.
requestMessage.Headers.TryAddWithoutValidation("X-Forwarded-For", context.Connection!.RemoteIpAddress!.ToString());
requestMessage.Headers.TryAddWithoutValidation("X-Forwarded-Proto", request.Scheme);
requestMessage.Headers.TryAddWithoutValidation("X-Forwarded-Host", request.Host.ToUriComponent());

Expand Down Expand Up @@ -129,7 +130,8 @@ public static async Task<bool> AcceptProxyWebSocketRequest(this HttpContext cont
}

AppendHeaderValue(client.Options, context.Request.Headers, "Via", context.Request.Protocol);
AppendHeaderValue(client.Options, context.Request.Headers, "X-Forwarded-For", context.Connection.RemoteIpAddress.ToString());
// TODO: Investigate possible null.
AppendHeaderValue(client.Options, context.Request.Headers, "X-Forwarded-For", context.Connection!.RemoteIpAddress!.ToString());
AppendHeaderValue(client.Options, context.Request.Headers, "X-Forwarded-Proto", context.Request.Scheme);
AppendHeaderValue(client.Options, context.Request.Headers, "X-Forwarded-Host", context.Request.Host.ToUriComponent());

Expand Down
18 changes: 14 additions & 4 deletions src/Microsoft.Tye.Hosting/Infrastructure/ServiceLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,35 @@ public ServiceLogger(string categoryName, Subject<string> logs)
_logs = logs;
}

public IDisposable? BeginScope<TState>(TState state)
public IDisposable BeginScope<TState>(TState state)
{
return null;
return new NoOpScope();
}

public bool IsEnabled(LogLevel logLevel)
{
return true;
}

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception, string>? formatter)
{
_logs.OnNext($"[{logLevel}]: {formatter(state, exception)}");
if (formatter != null && exception != null)
{
_logs.OnNext($"[{logLevel}]: {formatter(state, exception)}");
}

if (exception != null)
{
_logs.OnNext(exception.ToString());
}
}

private sealed class NoOpScope : IDisposable
{
public void Dispose()
{
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/Microsoft.Tye.Hosting/Microsoft.Tye.Hosting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Library</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Description>Orchestration host APIs.</Description>
<AssemblyName>Microsoft.Tye.Hosting</AssemblyName>
<PackageId>Microsoft.Tye.Hosting</PackageId>
Expand Down
12 changes: 8 additions & 4 deletions src/Microsoft.Tye.Hosting/ProxyService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public Task StartAsync(Application application)
return;
}

using var _ = cts.Token.Register(() => notificationFeature.RequestClose());
// TODO: Investigate possible null.
using var _ = cts.Token.Register(() => notificationFeature!.RequestClose());

NetworkStream? targetStream = null;

Expand Down Expand Up @@ -131,11 +132,13 @@ public Task StartAsync(Application application)
{
_logger.LogDebug("Proxying traffic to {ServiceName} {ExternalPort}:{InternalPort}", service.Description.Name, binding.Port, ports[next]);

// TODO: Investigate possible null.
// external -> internal
var reading = Task.Run(() => connection.Transport.Input.CopyToAsync(targetStream, notificationFeature.ConnectionClosedRequested));
var reading = Task.Run(() => connection.Transport.Input.CopyToAsync(targetStream, notificationFeature!.ConnectionClosedRequested));

// TODO: Investigate possible null.
// internal -> external
var writing = Task.Run(() => targetStream.CopyToAsync(connection.Transport.Output, notificationFeature.ConnectionClosedRequested));
var writing = Task.Run(() => targetStream.CopyToAsync(connection.Transport.Output, notificationFeature!.ConnectionClosedRequested));

await Task.WhenAll(reading, writing);
}
Expand All @@ -149,7 +152,8 @@ public Task StartAsync(Application application)
}
catch (OperationCanceledException ex)
{
if (!notificationFeature.ConnectionClosedRequested.IsCancellationRequested)
// TODO: Investigate possible null.
if (!notificationFeature!.ConnectionClosedRequested.IsCancellationRequested)
{
_logger.LogDebug(0, ex, "Proxy error for service {ServiceName}", service.Description.Name);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.Tye.Hosting/TransformProjectsIntoContainers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ private async Task TransformProjectToContainer(Service service, ProjectRunInfo p
// This is .NET specific
var userSecretStore = GetUserSecretsPathFromSecrets();

Directory.CreateDirectory(userSecretStore);

if (!string.IsNullOrEmpty(userSecretStore))
{
Directory.CreateDirectory(userSecretStore);

// Map the user secrets on this drive to user secrets
dockerRunInfo.VolumeMappings.Add(new DockerVolume(source: userSecretStore, name: null, target: "/root/.microsoft/usersecrets", readOnly: true));
}
Expand Down
7 changes: 4 additions & 3 deletions src/Microsoft.Tye.Hosting/TyeHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public async Task<IHost> StartAsync()

await app.StartAsync();

_addresses = DashboardWebApplication.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>().Addresses;
// TODO: Investigate possible null.
_addresses = DashboardWebApplication.Services.GetRequiredService<IServer>().Features.Get<IServerAddressesFeature>()!.Addresses;

_logger.LogInformation("Dashboard running on {Address}", _addresses.First());

Expand Down Expand Up @@ -333,7 +334,7 @@ private async Task StopAsync()
}
catch (Exception ex)
{
_logger.LogError(ex, "Error while shutting down");
_logger?.LogError(ex, "Error while shutting down");
}
finally
{
Expand Down Expand Up @@ -375,7 +376,7 @@ private void OpenDashboard(string url)
}
catch (Exception ex)
{
_logger.LogError(ex, "Error launching dashboard.");
_logger?.LogError(ex, "Error launching dashboard.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Tye.Proxy/Microsoft.Tye.Proxy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
14 changes: 9 additions & 5 deletions src/Microsoft.Tye.Proxy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ static async Task Main(string[] args)

logger.LogDebug("Attempting to connect to {ServiceName} listening on {Port}:{ExternalPort}", serviceName, mapping.Port, mapping.ExternalPort);

await target.ConnectAsync(containerHost, mapping.ExternalPort);
// TODO: Investigate null host.
await target.ConnectAsync(containerHost!, mapping.ExternalPort);

logger.LogDebug("Successfully connected to {ServiceName} listening on {Port}:{ExternalPort}", serviceName, mapping.Port, mapping.ExternalPort);

Expand All @@ -87,11 +88,13 @@ static async Task Main(string[] args)
{
logger.LogDebug("Proxying traffic to {ServiceName} {Port}:{ExternalPort}", serviceName, mapping.Port, mapping.ExternalPort);

// external -> internal
var reading = Task.Run(() => connection.Transport.Input.CopyToAsync(targetStream, notificationFeature.ConnectionClosedRequested));
// TODO: Investigate possible null.
// external -> internal
var reading = Task.Run(() => connection.Transport.Input.CopyToAsync(targetStream, notificationFeature!.ConnectionClosedRequested));

// TODO: Investigate possible null.
// internal -> external
var writing = Task.Run(() => targetStream.CopyToAsync(connection.Transport.Output, notificationFeature.ConnectionClosedRequested));
var writing = Task.Run(() => targetStream.CopyToAsync(connection.Transport.Output, notificationFeature!.ConnectionClosedRequested));

await Task.WhenAll(reading, writing);
}
Expand All @@ -105,7 +108,8 @@ static async Task Main(string[] args)
}
catch (OperationCanceledException ex)
{
if (!notificationFeature.ConnectionClosedRequested.IsCancellationRequested)
// TODO: Investigate possible null.
if (!notificationFeature!.ConnectionClosedRequested.IsCancellationRequested)
{
logger.LogDebug(0, ex, "Proxy error for service {ServiceName}", serviceName);
}
Expand Down
5 changes: 3 additions & 2 deletions src/shared/KubectlDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ public static Task<bool> IsKubectlConnectedToClusterAsync(OutputContext output)
{
continue;
}
var major = int.Parse(element.Value.GetProperty("major").GetString());
var minor = int.Parse(element.Value.GetProperty("minor").GetString().Trim('+'));
// TODO: Investigate possible null.
var major = int.Parse(element.Value!.GetProperty("major")!.GetString()!);
var minor = int.Parse(element.Value!.GetProperty("minor")!.GetString()!.Trim('+'));
var version = new Version(major, minor);
return version;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tye-diag-agent/tye-diag-agent.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Microsoft.Tye</RootNamespace>
</PropertyGroup>

Expand Down
3 changes: 2 additions & 1 deletion src/tye/InitHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public static (string, string) CreateTyeFileContent(FileInfo? path, bool force)
throw new CommandException(errorMessage!);
}

path = new FileInfo(filePath);
// TODO: Investigate possible null.
path = new FileInfo(filePath!);
}

var template = @"
Expand Down
2 changes: 1 addition & 1 deletion src/tye/tye.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Microsoft.Tye</RootNamespace>
<AssemblyName>tye</AssemblyName>
<PackageId>Microsoft.Tye</PackageId>
Expand Down
6 changes: 3 additions & 3 deletions test/E2ETest/ApplicationFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ public async Task TargetFrameworkFromCliArgs()
// Debug targets can be null if not specified, so make sure calling host.Start does not throw.
var outputContext = new OutputContext(_sink, Verbosity.Debug);
var projectFile = new FileInfo(yamlFile);
var applicationBuilder = await ApplicationFactory.CreateAsync(outputContext, projectFile, "netcoreapp3.1");
var applicationBuilder = await ApplicationFactory.CreateAsync(outputContext, projectFile, "net6.0");

Assert.Single(applicationBuilder.Services);
var service = applicationBuilder.Services.Single(s => s.Name == "multi-targetframeworks");

var containsTargetFramework = ((DotnetProjectServiceBuilder)service).BuildProperties.TryGetValue("TargetFramework", out var targetFramework);
Assert.True(containsTargetFramework);
Assert.Equal("netcoreapp3.1", targetFramework);
Assert.Equal("net6.0", targetFramework);
}

[Fact]
Expand All @@ -154,7 +154,7 @@ public async Task TargetFrameworkFromCliArgsDoesNotOverwriteYaml()
// Debug targets can be null if not specified, so make sure calling host.Start does not throw.
var outputContext = new OutputContext(_sink, Verbosity.Debug);
var projectFile = new FileInfo(yamlFile);
var applicationBuilder = await ApplicationFactory.CreateAsync(outputContext, projectFile, "netcoreapp3.1");
var applicationBuilder = await ApplicationFactory.CreateAsync(outputContext, projectFile, "net6.0");

Assert.Single(applicationBuilder.Services);
var service = applicationBuilder.Services.Single(s => s.Name == "multi-targetframeworks");
Expand Down
2 changes: 1 addition & 1 deletion test/E2ETest/Microsoft.Tye.E2ETests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>Microsoft.Tye.E2ETest</AssemblyName>
<IsTestProject>true</IsTestProject>
<IsUnitTestProject>true</IsUnitTestProject>
Expand Down
Loading