updated all packages and resolved errors

This commit is contained in:
Paul Dorsch 2023-01-04 17:08:06 -05:00
Родитель 57eb1243d5
Коммит ee12952289
144 изменённых файлов: 690 добавлений и 613 удалений

Просмотреть файл

@ -21,9 +21,9 @@ See https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build?v
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1">
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="7.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="SmartAnalyzers.CSharpExtensions.Annotations" Version="3.3.0" />
<!-- Add the same stylecop.json to all projects -->

Просмотреть файл

@ -8,8 +8,16 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="YamlDotNet" Version="12.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="YamlDotNet" Version="12.3.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.4.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.7" />
</ItemGroup>
</Project>

Просмотреть файл

@ -145,7 +145,7 @@ namespace Microsoft.Oryx.Automation
.FirstOrDefault();
if (versionElement != null)
{
this.prodSdkVersions.Add(versionElement.Value);
_ = this.prodSdkVersions.Add(versionElement.Value);
Console.WriteLine(versionElement.Value);
}
}

Просмотреть файл

@ -24,7 +24,7 @@ namespace Microsoft.Oryx.Automation
try
{
HttpResponseMessage response = await Client.GetAsync(url);
response.EnsureSuccessStatusCode();
_ = response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
return responseBody ?? string.Empty;

Просмотреть файл

@ -29,7 +29,7 @@ namespace Microsoft.Oryx.SharedCodeGenerator.Outputs.CSharp
this.className = this.collection.Name.Camelize();
this.directory = typeInfo["directory"];
this.namespaceProperty = typeInfo["namespace"];
typeInfo.TryGetValue("scope", out this.scope);
_ = typeInfo.TryGetValue("scope", out this.scope);
}
public string GetPath()

Просмотреть файл

@ -34,18 +34,18 @@ namespace Microsoft.Oryx.SharedCodeGenerator.Outputs
{
StringBuilder body = new StringBuilder();
var autoGeneratedMessage = Program.BuildAutogenDisclaimer(this.collection.SourcePath);
body.AppendLine($"<!-- {autoGeneratedMessage} -->"); // Can't use AppendLine becuase it appends \r\n
body.AppendLine();
body.AppendLine("<Project>");
body.AppendLine("\t<PropertyGroup>");
_ = body.AppendLine($"<!-- {autoGeneratedMessage} -->"); // Can't use AppendLine becuase it appends \r\n
_ = body.AppendLine();
_ = body.AppendLine("<Project>");
_ = body.AppendLine("\t<PropertyGroup>");
foreach (var constant in this.collection.Constants)
{
var name = constant.Key.Replace(ConstantCollection.NameSeparator[0], '_').ToUpper();
body.AppendLine($"\t\t<{name}>{constant.Value}</{name}>");
_ = body.AppendLine($"\t\t<{name}>{constant.Value}</{name}>");
}
body.AppendLine("\t</PropertyGroup>");
body.AppendLine("</Project>");
_ = body.AppendLine("\t</PropertyGroup>");
_ = body.AppendLine("</Project>");
return body.ToString();
}
}

Просмотреть файл

@ -17,7 +17,7 @@ namespace Microsoft.Oryx.SharedCodeGenerator.Outputs
public static IOutputFile CreateByType(Dictionary<string, string> typeInfo, ConstantCollection constantCollection)
{
string typeName = typeInfo["type"];
typeInfo.Remove("type");
_ = typeInfo.Remove("type");
IOutputFile outputFile = Activator.CreateInstance(OutputsByType[typeName]) as IOutputFile;
outputFile.Initialize(constantCollection, typeInfo);

Просмотреть файл

@ -35,15 +35,15 @@ namespace Microsoft.Oryx.SharedCodeGenerator.Outputs
{
StringBuilder body = new StringBuilder();
var autoGeneratedMessage = Program.BuildAutogenDisclaimer(this.collection.SourcePath);
body.AppendLine($"# {autoGeneratedMessage}");
body.AppendLine();
_ = body.AppendLine($"# {autoGeneratedMessage}");
_ = body.AppendLine();
if (this.collection.StringConstants?.Any() ?? false)
{
foreach (var constant in this.collection.StringConstants)
{
var name = constant.Key.Replace(ConstantCollection.NameSeparator[0], '_').ToUpper();
var value = constant.Value.WrapValueInQuotes();
body.AppendLine($"${name}={value}");
_ = body.AppendLine($"${name}={value}");
}
}

Просмотреть файл

@ -35,8 +35,8 @@ namespace Microsoft.Oryx.SharedCodeGenerator.Outputs
public string GetContent()
{
StringBuilder body = new StringBuilder();
body.Append("# " + Program.BuildAutogenDisclaimer(this.collection.SourcePath) + NewLine); // Can't use AppendLine becuase it appends \r\n
body.Append(NewLine);
_ = body.Append("# " + Program.BuildAutogenDisclaimer(this.collection.SourcePath) + NewLine); // Can't use AppendLine becuase it appends \r\n
_ = body.Append(NewLine);
if (this.collection.StringConstants?.Any() ?? false)
{
foreach (var constant in this.collection.StringConstants)
@ -45,7 +45,7 @@ namespace Microsoft.Oryx.SharedCodeGenerator.Outputs
var value = constant.Value.WrapValueInQuotes();
// Ex: PYTHON_VERSION='3.7.7'
body.Append($"{name}={value}{NewLine}");
_ = body.Append($"{name}={value}{NewLine}");
}
}
@ -61,7 +61,7 @@ namespace Microsoft.Oryx.SharedCodeGenerator.Outputs
: string.Empty;
// Ex: PYTHON_VERSIONS=("3.7.7" "3.8.0")
body.Append($"{name}=({value}){NewLine}");
_ = body.Append($"{name}=({value}){NewLine}");
}
}

Просмотреть файл

@ -9,9 +9,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2018.3.0" />
<PackageReference Include="Scriban.Signed" Version="1.2.9" />
<PackageReference Include="SemanticVersioning" Version="1.2.0" />
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" />
<PackageReference Include="Scriban.Signed" Version="5.5.2" />
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
<PackageReference Include="YamlDotNet.Signed" Version="5.3.0" />
</ItemGroup>
@ -24,4 +24,12 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.4.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.7" />
</ItemGroup>
</Project>

Просмотреть файл

@ -5,7 +5,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.Oryx.SharedCodeGenerator
{
@ -19,11 +18,11 @@ namespace Microsoft.Oryx.SharedCodeGenerator
this.Platform = platform;
if (this.nonSemverPlatforms.Contains(platform))
{
this.Version = new Version(this.DisplayVersion);
this.Version = new SemanticVersioning.Version(this.DisplayVersion);
}
else
{
this.SemanticVersion = new SemVer.Version(this.DisplayVersion, loose: true);
this.SemanticVersion = new SemanticVersioning.Version(this.DisplayVersion, loose: true);
}
}
@ -31,9 +30,9 @@ namespace Microsoft.Oryx.SharedCodeGenerator
public string Platform { get; }
public SemVer.Version SemanticVersion { get; }
public SemanticVersioning.Version SemanticVersion { get; }
public Version Version { get; }
public SemanticVersioning.Version Version { get; }
public int CompareTo(VersionInfo other) =>
this.nonSemverPlatforms.Contains(this.Platform)

Просмотреть файл

@ -16,16 +16,24 @@
<Import Project="$(MSBuildThisFileDirectory)\..\CommonFiles\AssemblyVersion.proj" />
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2018.3.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.10.0" />
<PackageReference Include="Microsoft.ApplicationInsights.NLogTarget" Version="2.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.5" />
<PackageReference Include="SemanticVersioning" Version="1.2.0" />
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights.NLogTarget" Version="2.21.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Oryx.Common\Common.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.4.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.7" />
</ItemGroup>
</Project>

Просмотреть файл

@ -55,7 +55,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Common
int headingWidth = this.rows.Max(t => t.Item1.Length);
foreach (var row in this.rows)
{
result.Append(row.Item1.PadRight(headingWidth) + HeadingSuffix);
_ = result.Append(row.Item1.PadRight(headingWidth) + HeadingSuffix);
if (string.IsNullOrWhiteSpace(row.Item2))
{
@ -64,10 +64,10 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Common
string[] lines = row.Item2.Split(new[] { "\r\n", "\n" }, StringSplitOptions.None);
result.AppendLine(lines[0]);
_ = result.AppendLine(lines[0]);
foreach (string line in lines.Skip(1))
{
result.Append(new string(' ', headingWidth + HeadingSuffix.Length)).AppendLine(line);
_ = result.Append(new string(' ', headingWidth + HeadingSuffix.Length)).AppendLine(line);
}
}

Просмотреть файл

@ -6,6 +6,7 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.ApplicationInsights.NLogTarget;
using Microsoft.Oryx.BuildScriptGenerator.Common;
using Microsoft.Oryx.Common.Extensions;
@ -92,7 +93,8 @@ namespace Microsoft.Extensions.Logging
private static TelemetryClient GetTelemetryClient()
{
var client = new TelemetryClient();
var config = TelemetryConfiguration.CreateDefault();
var client = new TelemetryClient(config);
ApplicationInsightsTarget aiTarget = (ApplicationInsightsTarget)NLog.LogManager.Configuration?.FindTargetByName("ai");
if (aiTarget != null)

Просмотреть файл

@ -30,11 +30,11 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Common
{
// Preserve the output structure and use AppendLine as these handlers
// are called for each line that is written to the output.
outputBuilder.AppendLine(args.Data);
_ = outputBuilder.AppendLine(args.Data);
},
standardErrorHandler: (sender, args) =>
{
errorBuilder.AppendLine(args.Data);
_ = errorBuilder.AppendLine(args.Data);
},
waitTimeForExit);

Просмотреть файл

@ -183,10 +183,10 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Common
// NOTE: do not use AppendLine as this script must be in one line
if (this.contentPresent)
{
this.scriptBuilder.Append(this.commandSeparator);
_ = this.scriptBuilder.Append(this.commandSeparator);
}
this.scriptBuilder.Append(content);
_ = this.scriptBuilder.Append(content);
this.contentPresent = true;
return this;
}

Просмотреть файл

@ -18,14 +18,14 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Common
public string DisplayVersion { get; }
public SemVer.Version SemanticVersion { get; }
public SemanticVersioning.Version SemanticVersion { get; }
public int CompareTo(VersionInfo other)
{
return this.SemanticVersion.CompareTo(other.SemanticVersion);
}
private static SemVer.Version ToSemanticVersion(string displayVersion)
private static SemanticVersioning.Version ToSemanticVersion(string displayVersion)
{
var semanticVersionStr = displayVersion;
@ -34,14 +34,14 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Common
// Throws ArgumentException if SemVer library found invalid version format.
if (displayVersion.Contains('-') || !displayVersion.Any(c => char.IsLetter(c)))
{
return new SemVer.Version(semanticVersionStr);
return new SemanticVersioning.Version(semanticVersionStr);
}
// The display version is an invalid preview version
var index = displayVersion.Length;
index = displayVersion.ToList().FindIndex(c => char.IsLetter(c));
semanticVersionStr = displayVersion.Insert(index, "-");
return new SemVer.Version(semanticVersionStr);
return new SemanticVersioning.Version(semanticVersionStr);
}
}
}

Просмотреть файл

@ -21,17 +21,17 @@
<Import Project="$(MSBuildThisFileDirectory)\..\CommonFiles\AssemblyVersion.proj" />
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.5" />
<PackageReference Include="Nett" Version="0.13.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Scriban.Signed" Version="1.2.9" />
<PackageReference Include="SemanticVersioning" Version="1.2.0" />
<PackageReference Include="System.CodeDom" Version="4.5.0" />
<PackageReference Include="YamlDotNet" Version="9.1.4" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Nett" Version="0.15.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Scriban.Signed" Version="5.5.2" />
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
<PackageReference Include="System.CodeDom" Version="7.0.0" />
<PackageReference Include="YamlDotNet" Version="12.3.1" />
</ItemGroup>
<ItemGroup>
@ -89,5 +89,13 @@
<ProjectReference Include="..\BuildScriptGenerator.Common\BuildScriptGenerator.Common.csproj" />
<ProjectReference Include="..\Detector\Detector.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.4.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.7" />
</ItemGroup>
</Project>

Просмотреть файл

@ -19,7 +19,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
{
public static IServiceCollection AddBuildScriptGeneratorServices(this IServiceCollection services)
{
services
_ = services
.AddPlatformDetectorServices()
.AddNodeScriptGeneratorServices()
.AddHugoScriptGeneratorServices()
@ -30,17 +30,17 @@ namespace Microsoft.Oryx.BuildScriptGenerator
.AddScriptGeneratorServicesGolang()
.AddScriptGeneratorServicesForJava();
services.AddSingleton<IBuildScriptGenerator, DefaultBuildScriptGenerator>();
services.AddSingleton<ICompatiblePlatformDetector, DefaultCompatiblePlatformDetector>();
services.AddSingleton<IDockerfileGenerator, DefaultDockerfileGenerator>();
services.AddSingleton<IEnvironment, DefaultEnvironment>();
services.AddSingleton<ISourceRepoProvider, DefaultSourceRepoProvider>();
services.AddSingleton<ITempDirectoryProvider, DefaulTempDirectoryProvider>();
services.AddSingleton<IScriptExecutor, DefaultScriptExecutor>();
services.AddSingleton<IRunScriptGenerator, DefaultRunScriptGenerator>();
services.AddSingleton<DefaultPlatformsInformationProvider>();
services.AddSingleton<PlatformsInstallationScriptProvider>();
services.AddHttpClient("general", httpClient =>
_ = services.AddSingleton<IBuildScriptGenerator, DefaultBuildScriptGenerator>();
_ = services.AddSingleton<ICompatiblePlatformDetector, DefaultCompatiblePlatformDetector>();
_ = services.AddSingleton<IDockerfileGenerator, DefaultDockerfileGenerator>();
_ = services.AddSingleton<IEnvironment, DefaultEnvironment>();
_ = services.AddSingleton<ISourceRepoProvider, DefaultSourceRepoProvider>();
_ = services.AddSingleton<ITempDirectoryProvider, DefaulTempDirectoryProvider>();
_ = services.AddSingleton<IScriptExecutor, DefaultScriptExecutor>();
_ = services.AddSingleton<IRunScriptGenerator, DefaultRunScriptGenerator>();
_ = services.AddSingleton<DefaultPlatformsInformationProvider>();
_ = services.AddSingleton<PlatformsInstallationScriptProvider>();
_ = services.AddHttpClient("general", httpClient =>
{
// NOTE: Setting user agent is required to avoid receiving 403 Forbidden response.
httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("oryx", "1.0"));

Просмотреть файл

@ -27,7 +27,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
public string GetTempDirectory()
{
// Ensure the temp directory is created
Directory.CreateDirectory(this.path);
_ = Directory.CreateDirectory(this.path);
return this.path;
}
}

Просмотреть файл

@ -36,10 +36,10 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
public override void InstallPlatformSpecificSkeletonDependencies(StringBuilder stringBuilder)
{
stringBuilder.AppendLine($"echo 'Installing {DotNetCoreConstants.PlatformName} specific dependencies...'");
_ = stringBuilder.AppendLine($"echo 'Installing {DotNetCoreConstants.PlatformName} specific dependencies...'");
// .NET Core dependencies (this is universal for all versions of .NET Core)
stringBuilder.AppendAptGetInstallPackages(
_ = stringBuilder.AppendAptGetInstallPackages(
"libc6",
"libgcc1",
"libgssapi-krb5-2",

Просмотреть файл

@ -15,11 +15,11 @@ namespace Microsoft.Oryx.BuildScriptGenerator
{
services.TryAddEnumerable(
ServiceDescriptor.Singleton<IProgrammingPlatform, DotNetCorePlatform>());
services.AddSingleton<IDotNetCoreVersionProvider, DotNetCoreVersionProvider>();
services.AddSingleton<DotNetCoreOnDiskVersionProvider>();
services.AddSingleton<DotNetCoreSdkStorageVersionProvider>();
services.AddSingleton<DotNetCorePlatformInstaller>();
services.AddSingleton<GlobalJsonSdkResolver>();
_ = services.AddSingleton<IDotNetCoreVersionProvider, DotNetCoreVersionProvider>();
_ = services.AddSingleton<DotNetCoreOnDiskVersionProvider>();
_ = services.AddSingleton<DotNetCoreSdkStorageVersionProvider>();
_ = services.AddSingleton<DotNetCorePlatformInstaller>();
_ = services.AddSingleton<GlobalJsonSdkResolver>();
return services;
}
}

Просмотреть файл

@ -51,7 +51,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
// We choose only the 'major' and 'minor' part of the runtime version.
// For example, 2.1.14 of runtime will result in a latest minor sdk in '1', for example
// 2.1.202 or 2.1.400
var version = new SemVer.Version(runtimeVersion);
var version = new SemanticVersioning.Version(runtimeVersion);
var globalJsonModel = new GlobalJsonModel
{
Sdk = new SdkModel

Просмотреть файл

@ -26,14 +26,14 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
if (!Directory.Exists(intermediateDir))
{
scriptBuilder
_ = scriptBuilder
.AppendLine()
.AppendLine("echo Intermediate directory does not exist, creating it...")
.AppendFormatWithLine("mkdir -p \"{0}\"", intermediateDir);
}
var excludeDirsSwitch = string.Join(" ", excludeDirs.Select(dir => $"--exclude \"{dir}\""));
scriptBuilder
_ = scriptBuilder
.AppendLine()
.AppendFormatWithLine("cd \"{0}\"", sourceDir)
.AppendLine("echo")
@ -60,7 +60,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
return scriptBuilder;
}
scriptBuilder
_ = scriptBuilder
.AppendLine()
.AppendFormatWithLine("cd \"{0}\"", sourceDir)
.AppendLine(preBuildCommand)
@ -78,7 +78,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
return scriptBuilder;
}
scriptBuilder
_ = scriptBuilder
.AppendLine()
.AppendFormatWithLine("cd \"{0}\"", sourceDir)
.AppendLine(postBuildCommand)
@ -92,27 +92,27 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
string destinationDir,
bool hasUserSuppliedDestinationDir)
{
scriptBuilder
_ = scriptBuilder
.AppendFormatWithLine("SOURCE_DIR=\"{0}\"", sourceDir)
.AppendLine("export SOURCE_DIR")
.AppendLine();
if (hasUserSuppliedDestinationDir)
{
scriptBuilder
_ = scriptBuilder
.AppendLine("echo")
.AppendSourceDirectoryInfo(sourceDir)
.AppendDestinationDirectoryInfo(destinationDir)
.AppendLine("echo")
.AppendFormatWithLine("mkdir -p \"{0}\"", destinationDir);
scriptBuilder
_ = scriptBuilder
.AppendFormatWithLine("DESTINATION_DIR=\"{0}\"", destinationDir)
.AppendLine("export DESTINATION_DIR");
}
else
{
scriptBuilder
_ = scriptBuilder
.AppendLine("echo")
.AppendSourceDirectoryInfo(sourceDir)
.AppendLine("echo");
@ -143,7 +143,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
return scriptBuilder;
}
scriptBuilder
_ = scriptBuilder
.AppendLine()
.AppendFormatWithLine("mkdir -p \"{0}\"", manifestFileDir)
.AppendLine("echo")
@ -156,7 +156,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
foreach (var property in buildProperties)
{
scriptBuilder.AppendFormatWithLine(
_ = scriptBuilder.AppendFormatWithLine(
"echo '{0}=\"{1}\"' >> \"{2}/{3}\"",
property.Key,
property.Value,
@ -164,13 +164,13 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
FilePaths.BuildManifestFileName);
}
scriptBuilder.AppendLine("echo Manifest file created.");
_ = scriptBuilder.AppendLine("echo Manifest file created.");
return scriptBuilder;
}
public static StringBuilder AddScriptToRestorePackages(this StringBuilder scriptBuilder, string projectFile)
{
scriptBuilder
_ = scriptBuilder
.AppendLine("echo")
.AppendLine("echo Restoring packages...")
.AppendFormatWithLine("dotnet restore \"{0}\"", projectFile);
@ -179,7 +179,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
public static StringBuilder AddScriptToBuildProject(this StringBuilder scriptBuilder, string projectFile)
{
scriptBuilder
_ = scriptBuilder
.AppendLine()
.AppendLine("echo")
.AppendFormatWithLine("echo \"Building project '{0}'\"", projectFile)
@ -196,7 +196,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
string buildConfiguration,
string finalDestinationDir)
{
scriptBuilder
_ = scriptBuilder
.AppendLine()
.AppendFormatWithLine(
"echo \"Publishing output to '{0}'\"",

Просмотреть файл

@ -28,7 +28,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
public static SdkVersionInfo Parse(string sdkVersion)
{
#pragma warning disable CA1806 // Ignore rule to handle boolean result of Try method
TryParse(sdkVersion, out var result);
_ = TryParse(sdkVersion, out var result);
#pragma warning restore CA1806
return result;
}

Просмотреть файл

@ -48,7 +48,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.DotNetCore
try
{
var version = new SemVer.Version(sdkVersionDir.Name);
var version = new SemanticVersioning.Version(sdkVersionDir.Name);
}
catch
{

Просмотреть файл

@ -272,7 +272,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Golang
golangVersion);
var script = this.golangInstaller.GetInstallerScriptSnippet(golangVersion);
scriptBuilder.AppendLine(script);
_ = scriptBuilder.AppendLine(script);
}
}
}

Просмотреть файл

@ -14,10 +14,10 @@ namespace Microsoft.Oryx.BuildScriptGenerator
public static IServiceCollection AddScriptGeneratorServicesGolang(this IServiceCollection services)
{
services.TryAddEnumerable(ServiceDescriptor.Singleton<IProgrammingPlatform, GolangPlatform>());
services.AddSingleton<IGolangVersionProvider, GolangVersionProvider>();
services.AddSingleton<GolangPlatformInstaller>();
services.AddSingleton<GolangOnDiskVersionProvider>();
services.AddSingleton<GolangSdkStorageVersionProvider>();
_ = services.AddSingleton<IGolangVersionProvider, GolangVersionProvider>();
_ = services.AddSingleton<GolangPlatformInstaller>();
_ = services.AddSingleton<GolangOnDiskVersionProvider>();
_ = services.AddSingleton<GolangSdkStorageVersionProvider>();
return services;
}
}

Просмотреть файл

@ -58,7 +58,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
var fullPath = Path.GetFullPath(fullyQualifiedPath);
if (File.Exists(Path.GetFullPath(fullPath)))
{
ProcessHelper.TrySetExecutableMode(fullPath);
_ = ProcessHelper.TrySetExecutableMode(fullPath);
return $"\"{fullPath}\"";
}

Просмотреть файл

@ -30,7 +30,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Hugo
var versionDirInTemp = Path.Combine(this.CommonOptions.DynamicInstallRootDir, platformName, version);
var snippet = new StringBuilder();
snippet
_ = snippet
.AppendLine()
.AppendLine("PLATFORM_SETUP_START=$SECONDS")
.AppendLine("echo")

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
public static IServiceCollection AddHugoScriptGeneratorServices(this IServiceCollection services)
{
services.TryAddEnumerable(ServiceDescriptor.Singleton<IProgrammingPlatform, HugoPlatform>());
services.AddSingleton<HugoPlatformInstaller>();
_ = services.AddSingleton<HugoPlatformInstaller>();
return services;
}
}

Просмотреть файл

@ -19,7 +19,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Java
public const string CompileCommandUsingMaven = "mvn clean compile";
public const string CreatePackageCommandUsingMavenWrapper = "./mvnw clean package";
public const string CompileCommandUsingMavenWrapper = "./mvnw clean compile";
public static readonly SemVer.Version
MinMavenVersionWithNoTransferProgressSupport = new SemVer.Version("3.6.1");
public static readonly SemanticVersioning.Version
MinMavenVersionWithNoTransferProgressSupport = new SemanticVersioning.Version("3.6.1");
}
}

Просмотреть файл

@ -138,7 +138,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Java
// Since the --quiet option is too quiet, we are trying to use a new switch below to just mute the
// messages related to transfer progress of these downloads.
// https://maven.apache.org/docs/3.6.1/release-notes.html#user-visible-changes
var currentMavenVersion = new SemVer.Version(javaPlatformDetectorResult.MavenVersion);
var currentMavenVersion = new SemanticVersioning.Version(javaPlatformDetectorResult.MavenVersion);
if (currentMavenVersion.CompareTo(JavaConstants.MinMavenVersionWithNoTransferProgressSupport) >= 0)
{
command = $"{command} --no-transfer-progress";
@ -355,7 +355,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Java
jdkVersion);
var script = this.javaPlatformInstaller.GetInstallerScriptSnippet(jdkVersion);
scriptBuilder.AppendLine(script);
_ = scriptBuilder.AppendLine(script);
}
}
@ -376,7 +376,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Java
mavenVersion);
var script = this.mavenInstaller.GetInstallerScriptSnippet(mavenVersion);
scriptBuilder.AppendLine(script);
_ = scriptBuilder.AppendLine(script);
}
}

Просмотреть файл

@ -15,14 +15,14 @@ namespace Microsoft.Oryx.BuildScriptGenerator
{
services.TryAddEnumerable(
ServiceDescriptor.Singleton<IProgrammingPlatform, JavaPlatform>());
services.AddSingleton<MavenInstaller>();
services.AddSingleton<JavaPlatformInstaller>();
services.AddSingleton<IJavaVersionProvider, JavaVersionProvider>();
services.AddSingleton<JavaOnDiskVersionProvider>();
services.AddSingleton<JavaSdkStorageVersionProvider>();
services.AddSingleton<IMavenVersionProvider, MavenVersionProvider>();
services.AddSingleton<MavenOnDiskVersionProvider>();
services.AddSingleton<MavenSdkStorageVersionProvider>();
_ = services.AddSingleton<MavenInstaller>();
_ = services.AddSingleton<JavaPlatformInstaller>();
_ = services.AddSingleton<IJavaVersionProvider, JavaVersionProvider>();
_ = services.AddSingleton<JavaOnDiskVersionProvider>();
_ = services.AddSingleton<JavaSdkStorageVersionProvider>();
_ = services.AddSingleton<IMavenVersionProvider, MavenVersionProvider>();
_ = services.AddSingleton<MavenOnDiskVersionProvider>();
_ = services.AddSingleton<MavenSdkStorageVersionProvider>();
return services;
}
}

Просмотреть файл

@ -59,7 +59,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Node
private static void CheckScript(IDictionary<string, string> scripts, string scriptKey, List<ICheckerMessage> result)
{
scripts.TryGetValue(scriptKey, out var script);
_ = scripts.TryGetValue(scriptKey, out var script);
if (script != null && NpmGlobalPattern.IsMatch(script))
{
result.Add(new CheckerMessage(string.Format(

Просмотреть файл

@ -334,7 +334,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Node
string compressNodeModulesCommand = null;
string compressedNodeModulesFileName = null;
GetNodeModulesPackOptions(ctx, out compressNodeModulesCommand, out compressedNodeModulesFileName);
_ = GetNodeModulesPackOptions(ctx, out compressNodeModulesCommand, out compressedNodeModulesFileName);
if (!string.IsNullOrWhiteSpace(compressedNodeModulesFileName))
{
@ -349,7 +349,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Node
string customRegistryUrl = null;
if (ctx.Properties != null)
{
ctx.Properties.TryGetValue(RegistryUrlPropertyKey, out customRegistryUrl);
_ = ctx.Properties.TryGetValue(RegistryUrlPropertyKey, out customRegistryUrl);
if (!string.IsNullOrWhiteSpace(customRegistryUrl))
{
// Write the custom registry to the build manifest
@ -360,7 +360,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Node
string packageDir = null;
if (ctx.Properties != null)
{
ctx.Properties.TryGetValue(PackageDirectoryPropertyKey, out packageDir);
_ = ctx.Properties.TryGetValue(PackageDirectoryPropertyKey, out packageDir);
if (!string.IsNullOrWhiteSpace(packageDir))
{
// Write the package directory to the build manifest

Просмотреть файл

@ -35,32 +35,32 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Node
public override void InstallPlatformSpecificSkeletonDependencies(StringBuilder stringBuilder)
{
stringBuilder.AppendLine($"echo 'Installing {NodeConstants.PlatformName} specific dependencies...'");
_ = stringBuilder.AppendLine($"echo 'Installing {NodeConstants.PlatformName} specific dependencies...'");
// Install Hugo and Yarn for node applications
stringBuilder.AppendLine("BUILD_DIR=\"/opt/tmp/build\"");
stringBuilder.AppendLine("IMAGES_DIR=\"/opt/tmp/images\"");
stringBuilder.AppendLine("${IMAGES_DIR}/build/installHugo.sh");
stringBuilder.AppendLine("set -ex");
stringBuilder.AppendLine("yarnCacheFolder=\"/usr/local/share/yarn-cache\"");
stringBuilder.AppendLine("mkdir -p $yarnCacheFolder");
stringBuilder.AppendLine("chmod 777 $yarnCacheFolder");
stringBuilder.AppendLine(". ${BUILD_DIR}/__nodeVersions.sh");
stringBuilder.AppendLine("${IMAGES_DIR}/receiveGpgKeys.sh 6A010C5166006599AA17F08146C2130DFD2497F5");
stringBuilder.AppendLine("${IMAGES_DIR}/retry.sh \"curl -fsSLO --compressed https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz\"");
stringBuilder.AppendLine("${IMAGES_DIR}/retry.sh \"curl -fsSLO --compressed https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc\"");
stringBuilder.AppendLine("gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz");
stringBuilder.AppendLine("mkdir -p /opt/yarn");
stringBuilder.AppendLine("tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn");
stringBuilder.AppendLine("mv /opt/yarn/yarn-v$YARN_VERSION /opt/yarn/$YARN_VERSION");
stringBuilder.AppendLine("rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz");
stringBuilder.AppendLine(". ${BUILD_DIR}/__nodeVersions.sh");
stringBuilder.AppendLine("ln -s $YARN_VERSION /opt/yarn/stable");
stringBuilder.AppendLine("ln -s $YARN_VERSION /opt/yarn/latest");
stringBuilder.AppendLine("ln -s $YARN_VERSION /opt/yarn/$YARN_MINOR_VERSION");
stringBuilder.AppendLine("ln -s $YARN_MINOR_VERSION /opt/yarn/$YARN_MAJOR_VERSION");
stringBuilder.AppendLine("mkdir -p /links");
stringBuilder.AppendLine("cp -s /opt/yarn/stable/bin/yarn /opt/yarn/stable/bin/yarnpkg /links");
_ = stringBuilder.AppendLine("BUILD_DIR=\"/opt/tmp/build\"");
_ = stringBuilder.AppendLine("IMAGES_DIR=\"/opt/tmp/images\"");
_ = stringBuilder.AppendLine("${IMAGES_DIR}/build/installHugo.sh");
_ = stringBuilder.AppendLine("set -ex");
_ = stringBuilder.AppendLine("yarnCacheFolder=\"/usr/local/share/yarn-cache\"");
_ = stringBuilder.AppendLine("mkdir -p $yarnCacheFolder");
_ = stringBuilder.AppendLine("chmod 777 $yarnCacheFolder");
_ = stringBuilder.AppendLine(". ${BUILD_DIR}/__nodeVersions.sh");
_ = stringBuilder.AppendLine("${IMAGES_DIR}/receiveGpgKeys.sh 6A010C5166006599AA17F08146C2130DFD2497F5");
_ = stringBuilder.AppendLine("${IMAGES_DIR}/retry.sh \"curl -fsSLO --compressed https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz\"");
_ = stringBuilder.AppendLine("${IMAGES_DIR}/retry.sh \"curl -fsSLO --compressed https://yarnpkg.com/downloads/$YARN_VERSION/yarn-v$YARN_VERSION.tar.gz.asc\"");
_ = stringBuilder.AppendLine("gpg --batch --verify yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz");
_ = stringBuilder.AppendLine("mkdir -p /opt/yarn");
_ = stringBuilder.AppendLine("tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/yarn");
_ = stringBuilder.AppendLine("mv /opt/yarn/yarn-v$YARN_VERSION /opt/yarn/$YARN_VERSION");
_ = stringBuilder.AppendLine("rm yarn-v$YARN_VERSION.tar.gz.asc yarn-v$YARN_VERSION.tar.gz");
_ = stringBuilder.AppendLine(". ${BUILD_DIR}/__nodeVersions.sh");
_ = stringBuilder.AppendLine("ln -s $YARN_VERSION /opt/yarn/stable");
_ = stringBuilder.AppendLine("ln -s $YARN_VERSION /opt/yarn/latest");
_ = stringBuilder.AppendLine("ln -s $YARN_VERSION /opt/yarn/$YARN_MINOR_VERSION");
_ = stringBuilder.AppendLine("ln -s $YARN_MINOR_VERSION /opt/yarn/$YARN_MAJOR_VERSION");
_ = stringBuilder.AppendLine("mkdir -p /links");
_ = stringBuilder.AppendLine("cp -s /opt/yarn/stable/bin/yarn /opt/yarn/stable/bin/yarnpkg /links");
InstallPythonToolingAndLanguage(stringBuilder);
}

Просмотреть файл

@ -15,10 +15,10 @@ namespace Microsoft.Oryx.BuildScriptGenerator
{
services.TryAddEnumerable(
ServiceDescriptor.Singleton<IProgrammingPlatform, NodePlatform>());
services.AddSingleton<INodeVersionProvider, NodeVersionProvider>();
services.AddSingleton<NodePlatformInstaller>();
services.AddSingleton<NodeOnDiskVersionProvider>();
services.AddSingleton<NodeSdkStorageVersionProvider>();
_ = services.AddSingleton<INodeVersionProvider, NodeVersionProvider>();
_ = services.AddSingleton<NodePlatformInstaller>();
_ = services.AddSingleton<NodeOnDiskVersionProvider>();
_ = services.AddSingleton<NodeSdkStorageVersionProvider>();
return services;
}
}

Просмотреть файл

@ -37,11 +37,11 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Php
public override void InstallPlatformSpecificSkeletonDependencies(StringBuilder stringBuilder)
{
stringBuilder.AppendLine($"echo 'Installing php-composer specific dependencies...'");
_ = stringBuilder.AppendLine($"echo 'Installing php-composer specific dependencies...'");
// Install an assortment of traditional tooling (unicode, SSL, HTTP, etc.)
stringBuilder.AppendLine("if [ \"${DEBIAN_FLAVOR}\" = \"buster\" ]; then");
stringBuilder.AppendAptGetInstallPackages(
_ = stringBuilder.AppendLine("if [ \"${DEBIAN_FLAVOR}\" = \"buster\" ]; then");
_ = stringBuilder.AppendAptGetInstallPackages(
"ca-certificates",
"libargon2-0",
"libcurl4-openssl-dev",
@ -52,11 +52,11 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Php
"libsqlite3-dev",
"libxml2-dev",
"xz-utils");
stringBuilder.AppendLine("else");
stringBuilder.AppendLine("tmpDir=\"/opt/tmp\"");
stringBuilder.AppendLine("imagesDir=\"$tmpDir/images\"");
stringBuilder.AppendLine("$imagesDir/build/php/prereqs/installPrereqs.sh");
stringBuilder.AppendAptGetInstallPackages(
_ = stringBuilder.AppendLine("else");
_ = stringBuilder.AppendLine("tmpDir=\"/opt/tmp\"");
_ = stringBuilder.AppendLine("imagesDir=\"$tmpDir/images\"");
_ = stringBuilder.AppendLine("$imagesDir/build/php/prereqs/installPrereqs.sh");
_ = stringBuilder.AppendAptGetInstallPackages(
"libcurl3",
"libicu57",
"liblttng-ust0",
@ -66,7 +66,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Php
"libncurses5-dev",
"libxml2-dev",
"libedit-dev");
stringBuilder.AppendLine("fi");
_ = stringBuilder.AppendLine("fi");
}
}
}

Просмотреть файл

@ -296,7 +296,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Php
phpVersion);
var script = this.phpInstaller.GetInstallerScriptSnippet(phpVersion);
scriptBuilder.AppendLine(script);
_ = scriptBuilder.AppendLine(script);
}
}
@ -322,7 +322,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Php
phpComposerVersion);
var script = this.phpComposerInstaller.GetInstallerScriptSnippet(phpComposerVersion);
scriptBuilder.AppendLine(script);
_ = scriptBuilder.AppendLine(script);
}
}

Просмотреть файл

@ -37,11 +37,11 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Php
public override void InstallPlatformSpecificSkeletonDependencies(StringBuilder stringBuilder)
{
stringBuilder.AppendLine($"echo 'Installing {PhpConstants.PlatformName} specific dependencies...'");
_ = stringBuilder.AppendLine($"echo 'Installing {PhpConstants.PlatformName} specific dependencies...'");
// Install an assortment of traditional tooling (unicode, SSL, HTTP, etc.)
stringBuilder.AppendLine("if [ \"${DEBIAN_FLAVOR}\" = \"buster\" ]; then");
stringBuilder.AppendAptGetInstallPackages(
_ = stringBuilder.AppendLine("if [ \"${DEBIAN_FLAVOR}\" = \"buster\" ]; then");
_ = stringBuilder.AppendAptGetInstallPackages(
"ca-certificates",
"libargon2-0",
"libcurl4-openssl-dev",
@ -52,11 +52,11 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Php
"libsqlite3-dev",
"libxml2-dev",
"xz-utils");
stringBuilder.AppendLine("else");
stringBuilder.AppendLine("tmpDir=\"/opt/tmp\"");
stringBuilder.AppendLine("imagesDir=\"$tmpDir/images\"");
stringBuilder.AppendLine("$imagesDir/build/php/prereqs/installPrereqs.sh");
stringBuilder.AppendAptGetInstallPackages(
_ = stringBuilder.AppendLine("else");
_ = stringBuilder.AppendLine("tmpDir=\"/opt/tmp\"");
_ = stringBuilder.AppendLine("imagesDir=\"$tmpDir/images\"");
_ = stringBuilder.AppendLine("$imagesDir/build/php/prereqs/installPrereqs.sh");
_ = stringBuilder.AppendAptGetInstallPackages(
"libcurl3",
"libicu57",
"liblttng-ust0",
@ -66,7 +66,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Php
"libncurses5-dev",
"libxml2-dev",
"libedit-dev");
stringBuilder.AppendLine("fi");
_ = stringBuilder.AppendLine("fi");
}
}
}

Просмотреть файл

@ -14,14 +14,14 @@ namespace Microsoft.Oryx.BuildScriptGenerator
public static IServiceCollection AddPhpScriptGeneratorServices(this IServiceCollection services)
{
services.TryAddEnumerable(ServiceDescriptor.Singleton<IProgrammingPlatform, PhpPlatform>());
services.AddSingleton<IPhpVersionProvider, PhpVersionProvider>();
services.AddSingleton<IPhpComposerVersionProvider, PhpComposerVersionProvider>();
services.AddSingleton<PhpPlatformInstaller>();
services.AddSingleton<PhpComposerInstaller>();
services.AddSingleton<PhpOnDiskVersionProvider>();
services.AddSingleton<PhpComposerOnDiskVersionProvider>();
services.AddSingleton<PhpSdkStorageVersionProvider>();
services.AddSingleton<PhpComposerSdkStorageVersionProvider>();
_ = services.AddSingleton<IPhpVersionProvider, PhpVersionProvider>();
_ = services.AddSingleton<IPhpComposerVersionProvider, PhpComposerVersionProvider>();
_ = services.AddSingleton<PhpPlatformInstaller>();
_ = services.AddSingleton<PhpComposerInstaller>();
_ = services.AddSingleton<PhpOnDiskVersionProvider>();
_ = services.AddSingleton<PhpComposerOnDiskVersionProvider>();
_ = services.AddSingleton<PhpSdkStorageVersionProvider>();
_ = services.AddSingleton<PhpComposerSdkStorageVersionProvider>();
return services;
}
}

Просмотреть файл

@ -33,17 +33,17 @@ namespace Microsoft.Oryx.BuildScriptGenerator
/// </summary>
public static void InstallCommonSkeletonDependencies(StringBuilder stringBuilder)
{
stringBuilder.AppendLine("echo 'Installing common platform dependencies...'");
stringBuilder.AppendAptGetInstallPackages("git");
_ = stringBuilder.AppendLine("echo 'Installing common platform dependencies...'");
_ = stringBuilder.AppendAptGetInstallPackages("git");
}
public static void InstallPythonToolingAndLanguage(StringBuilder stringBuilder)
{
stringBuilder.AppendLine("echo 'Installing python tooling and language...'");
_ = stringBuilder.AppendLine("echo 'Installing python tooling and language...'");
// Install Python tooling
stringBuilder.AppendLine("PYTHONIOENCODING=\"UTF-8\"");
stringBuilder.AppendAptGetInstallPackages(
_ = stringBuilder.AppendLine("PYTHONIOENCODING=\"UTF-8\"");
_ = stringBuilder.AppendAptGetInstallPackages(
"make",
"unzip",
"build-essential",
@ -56,27 +56,27 @@ namespace Microsoft.Oryx.BuildScriptGenerator
"uuid-dev");
// Install Python 3.8
stringBuilder.AppendLine("tmpDir=\"/opt/tmp\"");
stringBuilder.AppendLine("imagesDir=\"$tmpDir/images\"");
stringBuilder.AppendLine("buildDir=\"$tmpDir/build\"");
stringBuilder.AppendLine("mkdir -p /usr/local/share/pip-cache/lib");
stringBuilder.AppendLine("chmod -R 777 /usr/local/share/pip-cache");
stringBuilder.AppendLine("pip3 install pip --upgrade");
stringBuilder.AppendLine("python3 -m pip install --upgrade cython");
stringBuilder.AppendLine("pip3 install --upgrade cython");
stringBuilder.AppendLine(". $buildDir/__pythonVersions.sh");
stringBuilder.AppendLine("$imagesDir/installPlatform.sh python $PYTHON38_VERSION");
stringBuilder.AppendLine("[ -d \"/opt/python/$PYTHON38_VERSION\" ] && echo /opt/python/$PYTHON38_VERSION/lib >> /etc/ld.so.conf.d/python.conf");
stringBuilder.AppendLine("ldconfig");
stringBuilder.AppendLine("cd /opt/python");
stringBuilder.AppendLine("ln -s $PYTHON38_VERSION 3.8");
stringBuilder.AppendLine("ln -s $PYTHON38_VERSION latest");
stringBuilder.AppendLine("ln -s $PYTHON38_VERSION stable");
_ = stringBuilder.AppendLine("tmpDir=\"/opt/tmp\"");
_ = stringBuilder.AppendLine("imagesDir=\"$tmpDir/images\"");
_ = stringBuilder.AppendLine("buildDir=\"$tmpDir/build\"");
_ = stringBuilder.AppendLine("mkdir -p /usr/local/share/pip-cache/lib");
_ = stringBuilder.AppendLine("chmod -R 777 /usr/local/share/pip-cache");
_ = stringBuilder.AppendLine("pip3 install pip --upgrade");
_ = stringBuilder.AppendLine("python3 -m pip install --upgrade cython");
_ = stringBuilder.AppendLine("pip3 install --upgrade cython");
_ = stringBuilder.AppendLine(". $buildDir/__pythonVersions.sh");
_ = stringBuilder.AppendLine("$imagesDir/installPlatform.sh python $PYTHON38_VERSION");
_ = stringBuilder.AppendLine("[ -d \"/opt/python/$PYTHON38_VERSION\" ] && echo /opt/python/$PYTHON38_VERSION/lib >> /etc/ld.so.conf.d/python.conf");
_ = stringBuilder.AppendLine("ldconfig");
_ = stringBuilder.AppendLine("cd /opt/python");
_ = stringBuilder.AppendLine("ln -s $PYTHON38_VERSION 3.8");
_ = stringBuilder.AppendLine("ln -s $PYTHON38_VERSION latest");
_ = stringBuilder.AppendLine("ln -s $PYTHON38_VERSION stable");
}
public virtual void InstallPlatformSpecificSkeletonDependencies(StringBuilder stringBuilder)
{
stringBuilder.AppendLine("echo 'No platform specific dependencies to install.'");
_ = stringBuilder.AppendLine("echo 'No platform specific dependencies to install.'");
}
protected string GetInstallerScriptSnippet(
@ -95,7 +95,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
var tarFile = $"{version}.tar.gz";
var snippet = new StringBuilder();
snippet
_ = snippet
.AppendLine()
.AppendLine($"if grep -q cli \"/opt/oryx/.imagetype\"; then")
.AppendCommonSkeletonDepenendenciesInstallation()

Просмотреть файл

@ -55,8 +55,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator
var snippets = this.GetInstallationScriptSnippets(detectionResults, context);
foreach (var snippet in snippets)
{
scriptBuilder.AppendLine(snippet);
scriptBuilder.AppendLine();
_ = scriptBuilder.AppendLine(snippet);
_ = scriptBuilder.AppendLine();
}
return scriptBuilder.ToString();

Просмотреть файл

@ -231,7 +231,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Python
virtualEnvModule);
}
GetVirtualEnvPackOptions(
_ = GetVirtualEnvPackOptions(
context,
virtualEnvName,
out var compressVirtualEnvCommand,
@ -430,7 +430,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Python
string packageDir = null;
if (context.Properties != null)
{
context.Properties.TryGetValue(TargetPackageDirectoryPropertyKey, out packageDir);
_ = context.Properties.TryGetValue(TargetPackageDirectoryPropertyKey, out packageDir);
}
return packageDir;
@ -553,7 +553,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Python
{
string pythonVersion;
string templateName;
var version = new SemVer.Version(detectorResult.PlatformVersion);
var version = new SemanticVersioning.Version(detectorResult.PlatformVersion);
if (version.Major.Equals(2))
{
templateName = CondaConstants.DefaultPython2CondaEnvironmentYmlFileTemplateName;

Просмотреть файл

@ -34,7 +34,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Python
public override void InstallPlatformSpecificSkeletonDependencies(StringBuilder stringBuilder)
{
stringBuilder.AppendLine($"echo 'Installing {PythonConstants.PlatformName} specific dependencies...'");
_ = stringBuilder.AppendLine($"echo 'Installing {PythonConstants.PlatformName} specific dependencies...'");
InstallPythonToolingAndLanguage(stringBuilder);
}

Просмотреть файл

@ -15,10 +15,10 @@ namespace Microsoft.Oryx.BuildScriptGenerator
{
services.TryAddEnumerable(
ServiceDescriptor.Singleton<IProgrammingPlatform, PythonPlatform>());
services.AddSingleton<IPythonVersionProvider, PythonVersionProvider>();
services.AddSingleton<PythonPlatformInstaller>();
services.AddSingleton<PythonOnDiskVersionProvider>();
services.AddSingleton<PythonSdkStorageVersionProvider>();
_ = services.AddSingleton<IPythonVersionProvider, PythonVersionProvider>();
_ = services.AddSingleton<PythonPlatformInstaller>();
_ = services.AddSingleton<PythonOnDiskVersionProvider>();
_ = services.AddSingleton<PythonSdkStorageVersionProvider>();
return services;
}
}

Просмотреть файл

@ -256,7 +256,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Ruby
rubyVersion);
var script = this.rubyInstaller.GetInstallerScriptSnippet(rubyVersion);
scriptBuilder.AppendLine(script);
_ = scriptBuilder.AppendLine(script);
}
}

Просмотреть файл

@ -34,9 +34,9 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Ruby
public override void InstallPlatformSpecificSkeletonDependencies(StringBuilder stringBuilder)
{
stringBuilder.AppendLine($"echo 'Installing {RubyConstants.PlatformName} specific dependencies...'");
_ = stringBuilder.AppendLine($"echo 'Installing {RubyConstants.PlatformName} specific dependencies...'");
stringBuilder.AppendAptGetInstallPackages(
_ = stringBuilder.AppendAptGetInstallPackages(
"libreadline-dev",
"bzip2",
"build-essential",

Просмотреть файл

@ -14,10 +14,10 @@ namespace Microsoft.Oryx.BuildScriptGenerator
public static IServiceCollection AddScriptGeneratorServicesRuby(this IServiceCollection services)
{
services.TryAddEnumerable(ServiceDescriptor.Singleton<IProgrammingPlatform, RubyPlatform>());
services.AddSingleton<IRubyVersionProvider, RubyVersionProvider>();
services.AddSingleton<RubyPlatformInstaller>();
services.AddSingleton<RubyOnDiskVersionProvider>();
services.AddSingleton<RubySdkStorageVersionProvider>();
_ = services.AddSingleton<IRubyVersionProvider, RubyVersionProvider>();
_ = services.AddSingleton<RubyPlatformInstaller>();
_ = services.AddSingleton<RubyOnDiskVersionProvider>();
_ = services.AddSingleton<RubySdkStorageVersionProvider>();
return services;
}
}

Просмотреть файл

@ -13,7 +13,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
{
public static StringBuilder AppendSourceDirectoryInfo(this StringBuilder stringBuilder, string sourceDir)
{
stringBuilder
_ = stringBuilder
.AppendFormatWithLine("echo Source directory : {0}", sourceDir)
.AppendLine();
return stringBuilder;
@ -23,7 +23,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
this StringBuilder stringBuilder,
string destinationDir)
{
stringBuilder
_ = stringBuilder
.AppendFormatWithLine("echo Destination directory : {0}", destinationDir)
.AppendLine();
return stringBuilder;
@ -34,7 +34,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
var benvPath = FilePaths.Benv;
if (File.Exists(benvPath))
{
stringBuilder
_ = stringBuilder
.AppendFormatWithLine("source {0} {1}", benvPath, benvArgs)
.AppendLine();
}
@ -58,11 +58,11 @@ namespace Microsoft.Oryx.BuildScriptGenerator
public static StringBuilder AppendAptGetInstallPackages(this StringBuilder stringBuilder, params string[] packagesToInstall)
{
stringBuilder.AppendLine("apt-get update");
stringBuilder.AppendLine("apt-get upgrade -y");
stringBuilder.AppendLine("apt-get install -y --no-install-recommends \\");
stringBuilder.AppendLine($" {string.Join(" ", packagesToInstall)}");
stringBuilder.AppendLine("rm -rf /var/lib/apt/lists/*");
_ = stringBuilder.AppendLine("apt-get update");
_ = stringBuilder.AppendLine("apt-get upgrade -y");
_ = stringBuilder.AppendLine("apt-get install -y --no-install-recommends \\");
_ = stringBuilder.AppendLine($" {string.Join(" ", packagesToInstall)}");
_ = stringBuilder.AppendLine("rm -rf /var/lib/apt/lists/*");
return stringBuilder;
}
@ -99,8 +99,8 @@ namespace Microsoft.Oryx.BuildScriptGenerator
string format,
params object[] args)
{
stringBuilder.AppendFormat(format, args);
stringBuilder.AppendLine();
_ = stringBuilder.AppendFormat(format, args);
_ = stringBuilder.AppendLine();
return stringBuilder;
}
}

Просмотреть файл

@ -7,7 +7,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
{
using System.Collections.Generic;
using System.Linq;
using SemVer;
using SemanticVersioning;
using Version = System.Version;
internal static class SemanticVersionResolver

Просмотреть файл

@ -39,12 +39,12 @@ namespace Microsoft.Oryx.BuildScriptGenerator
return Enumerable.Empty<string>();
}
var versions = new List<SemVer.Version>();
var versions = new List<SemanticVersioning.Version>();
foreach (var versionDir in versionDirectories)
{
try
{
var version = new SemVer.Version(versionDir.Name);
var version = new SemanticVersioning.Version(versionDir.Name);
versions.Add(version);
}
catch (ArgumentException)

Просмотреть файл

@ -13,6 +13,8 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AssemblyVersion>0.2</AssemblyVersion>
<HighEntropyVA>true</HighEntropyVA>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<DisableCheckingDuplicateNuGetItems>true</DisableCheckingDuplicateNuGetItems>
<!-- Remove when proper XML documentation is added to the project. -->
<DisableDocRequirement>true</DisableDocRequirement>
</PropertyGroup>
@ -20,19 +22,22 @@
<Import Project="$(MSBuildThisFileDirectory)\..\CommonFiles\AssemblyVersion.proj" />
<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.3.4" />
<PackageReference Include="Microsoft.ApplicationInsights.NLogTarget" Version="2.10.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.5" />
<PackageReference Include="Microsoft.VisualStudioEng.MicroBuild.Core" Version="0.4.1" />
<PackageReference Include="NLog" Version="4.6.5" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.5.1" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.2" />
<PackageReference Include="Microsoft.ApplicationInsights.NLogTarget" Version="2.21.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.0" />
<PackageReference Include="Microsoft.VisualStudioEng.MicroBuild.Core" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NLog" Version="5.1.1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
</ItemGroup>
<ItemGroup>
@ -46,4 +51,8 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.7" />
</ItemGroup>
</Project>

Просмотреть файл

@ -14,14 +14,14 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
{
public static IServiceCollection AddCliServices(this IServiceCollection services, IConsole console = null)
{
services.AddOptionsServices();
services.AddSingleton<IConsole, PhysicalConsole>();
services.AddSingleton<CliEnvironmentSettings>();
_ = services.AddOptionsServices();
_ = services.AddSingleton<IConsole, PhysicalConsole>();
_ = services.AddSingleton<CliEnvironmentSettings>();
return console == null ?
services.AddSingleton<IStandardOutputWriter, DefaultStandardOutputWriter>() :
services.AddSingleton<IStandardOutputWriter>(new DefaultStandardOutputWriter(
(message) => { console.Write(message); },
(message) => { console.WriteLine(message); }));
(message) => { _ = console.Write(message); },
(message) => { _ = console.WriteLine(message); }));
}
}
}

Просмотреть файл

@ -98,8 +98,8 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
{
string result = LoggingConstants.DefaultOperationName;
LoggingConstants.EnvTypeOperationNamePrefix.TryGetValue(env.Type, out string prefix);
LoggingConstants.OperationNameSourceEnvVars.TryGetValue(env.Type, out string opNameSrcVarName);
_ = LoggingConstants.EnvTypeOperationNamePrefix.TryGetValue(env.Type, out string prefix);
_ = LoggingConstants.OperationNameSourceEnvVars.TryGetValue(env.Type, out string opNameSrcVarName);
if (string.IsNullOrEmpty(prefix) || string.IsNullOrEmpty(opNameSrcVarName))
{
return result;
@ -150,25 +150,25 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
var options = serviceProvider.GetRequiredService<IOptions<BuildScriptGeneratorOptions>>().Value;
var beginningOutputLog = GetBeginningCommandOutputLog();
console.WriteLine(beginningOutputLog);
_ = console.WriteLine(beginningOutputLog);
var buildInfo = new DefinitionListFormatter();
buildInfo.AddDefinition("Build Operation ID", buildOperationId);
_ = buildInfo.AddDefinition("Build Operation ID", buildOperationId);
if (!string.IsNullOrWhiteSpace(sourceRepoCommitId))
{
buildInfo.AddDefinition("Repository Commit", sourceRepoCommitId);
_ = buildInfo.AddDefinition("Repository Commit", sourceRepoCommitId);
}
if (!string.IsNullOrWhiteSpace(options.DebianFlavor))
{
buildInfo.AddDefinition("OS Type", options.DebianFlavor);
_ = buildInfo.AddDefinition("OS Type", options.DebianFlavor);
}
if (!string.IsNullOrWhiteSpace(options.ImageType))
{
buildInfo.AddDefinition("Image Type", options.ImageType);
_ = buildInfo.AddDefinition("Image Type", options.ImageType);
}
console.WriteLine(buildInfo.ToString());
_ = console.WriteLine(buildInfo.ToString());
// Generate build script
string scriptContent;
@ -186,7 +186,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
{
var messageFormatter = new DefinitionListFormatter();
checkerMessages.ForEach(msg => messageFormatter.AddDefinition(msg.Level.ToString(), msg.Content));
console.WriteLine(messageFormatter.ToString());
_ = console.WriteLine(messageFormatter.ToString());
}
else
{
@ -213,7 +213,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
logger.LogTrace("Build script written to file");
if (this.DebugMode)
{
console.WriteLine($"Build script content:\n{scriptContent}");
_ = console.WriteLine($"Build script content:\n{scriptContent}");
}
// Merge the earlier build event properties
@ -240,8 +240,8 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
return;
}
console.WriteLine(line);
buildScriptOutput.AppendLine(line);
_ = console.WriteLine(line);
_ = buildScriptOutput.AppendLine(line);
foreach (var processor in stdOutEventLoggers)
{
@ -271,14 +271,14 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
// Not using IConsole.WriteErrorLine intentionally, to keep the child's error stream intact
console.Error.WriteLine(line);
buildScriptOutput.AppendLine(line);
_ = buildScriptOutput.AppendLine(line);
};
// Run the generated script
int exitCode;
using (var timedEvent = logger.LogTimedEvent("RunBuildScript", buildEventProps))
{
console.WriteLine();
_ = console.WriteLine();
exitCode = serviceProvider.GetRequiredService<IScriptExecutor>().ExecuteScript(
buildScriptPath,
new[]
@ -320,13 +320,13 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
if (this.languageWasSet)
{
logger.LogWarning("Deprecated option '--language' used");
console.WriteLine("Warning: the deprecated option '--language' was used.");
_ = console.WriteLine("Warning: the deprecated option '--language' was used.");
}
if (this.languageVersionWasSet)
{
logger.LogWarning("Deprecated option '--language-version' used");
console.WriteLine("Warning: the deprecated option '--language-version' was used.");
_ = console.WriteLine("Warning: the deprecated option '--language-version' was used.");
}
// Invalid to specify platform version without platform name
@ -409,7 +409,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
// We first add IConfiguration to DI so that option services like
// `DotNetCoreScriptGeneratorOptionsSetup` services can get it through DI and read from the config
// and set the options.
services
_ = services
.AddSingleton<IConfiguration>(config)
.AddOptionsServices()
.Configure<BuildScriptGeneratorOptions>(options =>

Просмотреть файл

@ -83,7 +83,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
{
if (this.DebugMode)
{
console.WriteLine(
_ = console.WriteLine(
$"Warning: DEBIAN_FLAVOR environment variable not found. " +
$"Falling back to debian flavor in the {FilePaths.OsTypeFileName} file.");
}
@ -114,14 +114,14 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
options.ImageType = parsedImageType;
if (this.DebugMode)
{
console.WriteLine($"Parsed image type from file '{FilePaths.ImageTypeFileName}': {options.ImageType}");
_ = console.WriteLine($"Parsed image type from file '{FilePaths.ImageTypeFileName}': {options.ImageType}");
}
}
else
{
if (this.DebugMode)
{
console.WriteLine($"Warning: '{FilePaths.ImageTypeFileName}' file not found.");
_ = console.WriteLine($"Warning: '{FilePaths.ImageTypeFileName}' file not found.");
}
}
}

Просмотреть файл

@ -49,15 +49,15 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
if (string.IsNullOrEmpty(this.OutputPath))
{
console.WriteLine(generatedScript);
_ = console.WriteLine(generatedScript);
}
else
{
this.OutputPath.SafeWriteAllText(generatedScript);
console.WriteLine($"Script written to '{this.OutputPath}'");
_ = console.WriteLine($"Script written to '{this.OutputPath}'");
// Try making the script executable
ProcessHelper.TrySetExecutableMode(this.OutputPath);
_ = ProcessHelper.TrySetExecutableMode(this.OutputPath);
}
return ProcessConstants.ExitSuccess;
@ -111,7 +111,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
.AddEnvironmentVariables()
.Build();
services.AddSingleton<IConfiguration>(configuration);
_ = services.AddSingleton<IConfiguration>(configuration);
})
.ConfigureScriptGenerationOptions(opts =>
{

Просмотреть файл

@ -97,8 +97,8 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
if (compatPlats != null && compatPlats.Any())
{
console.WriteLine("Detected platforms:");
console.WriteLine(string.Join(' ', compatPlats.Select(pair => $"{pair.Key.Name}=\"{pair.Value}\"")));
_ = console.WriteLine("Detected platforms:");
_ = console.WriteLine(string.Join(' ', compatPlats.Select(pair => $"{pair.Key.Name}=\"{pair.Value}\"")));
// Write the detected platforms into the build plan as TOML
File.WriteAllLines(this.PlanPath, compatPlats.Select(pair => $"{pair.Key.Name} = {{ version = \"{pair.Value}\" }}"));

Просмотреть файл

@ -79,7 +79,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
if (this.DebugMode)
{
console.WriteLine("Debug mode enabled");
_ = console.WriteLine("Debug mode enabled");
}
using (var timedEvent = logger?.LogTimedEvent(this.GetType().Name))
@ -132,7 +132,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
// Add an empty and default configuration to prevent some commands from breaking since options
// setup expect this from DI.
var configuration = new ConfigurationBuilder().Build();
services.AddSingleton<IConfiguration>(configuration);
_ = services.AddSingleton<IConfiguration>(configuration);
})
.ConfigureScriptGenerationOptions(opts => this.ConfigureBuildScriptGeneratorOptions(opts));
return serviceProviderBuilder.Build();
@ -141,19 +141,19 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
protected static string GetBeginningCommandOutputLog()
{
var output = new StringBuilder();
output.AppendLine("Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx");
output.AppendLine("You can report issues at https://github.com/Microsoft/Oryx/issues");
_ = output.AppendLine("Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx");
_ = output.AppendLine("You can report issues at https://github.com/Microsoft/Oryx/issues");
var buildInfo = new DefinitionListFormatter();
var oryxVersion = Program.GetVersion();
var oryxCommitId = Program.GetMetadataValue(Program.GitCommit);
var oryxReleaseTagName = Program.GetMetadataValue(Program.ReleaseTagName);
buildInfo.AddDefinition(
_ = buildInfo.AddDefinition(
"Oryx Version",
$"{oryxVersion}, " +
$"Commit: {oryxCommitId}, " +
$"ReleaseTagName: {oryxReleaseTagName}");
output.AppendLine();
output.Append(buildInfo.ToString());
_ = output.AppendLine();
_ = output.Append(buildInfo.ToString());
return output.ToString();
}

Просмотреть файл

@ -101,9 +101,9 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
var defs = new DefinitionListFormatter();
if (detectedPlatformResults == null || !detectedPlatformResults.Any())
{
defs.AddDefinition("Platform", "Not Detected");
defs.AddDefinition("PlatformVersion", "Not Detected");
console.WriteLine(defs.ToString());
_ = defs.AddDefinition("Platform", "Not Detected");
_ = defs.AddDefinition("PlatformVersion", "Not Detected");
_ = console.WriteLine(defs.ToString());
return;
}
@ -129,18 +129,18 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
propertyString = propertyValue == null ? "Not Detected" : propertyValue.ToString();
}
defs.AddDefinition(propertyInfo.Name, propertyString);
_ = defs.AddDefinition(propertyInfo.Name, propertyString);
}
}
console.WriteLine(defs.ToString());
_ = console.WriteLine(defs.ToString());
}
private static void PrintJsonResult(IEnumerable<PlatformDetectorResult> detectedPlatformResults, IConsole console)
{
if (detectedPlatformResults == null || !detectedPlatformResults.Any())
{
console.WriteLine("{}");
_ = console.WriteLine("{}");
return;
}
@ -149,7 +149,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
detectedPlatformResult.PlatformVersion = detectedPlatformResult.PlatformVersion ?? string.Empty;
}
console.WriteLine(JsonConvert.SerializeObject(detectedPlatformResults, Formatting.Indented));
_ = console.WriteLine(JsonConvert.SerializeObject(detectedPlatformResults, Formatting.Indented));
}
}
}

Просмотреть файл

@ -110,13 +110,13 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
exitCode = ProcessConstants.ExitSuccess;
if (string.IsNullOrEmpty(this.OutputPath))
{
console.WriteLine(dockerfile);
_ = console.WriteLine(dockerfile);
}
else
{
this.OutputPath.SafeWriteAllText(dockerfile);
this.OutputPath = Path.GetFullPath(this.OutputPath).TrimEnd('/').TrimEnd('\\');
console.WriteLine($"Dockerfile written to '{this.OutputPath}'.");
_ = console.WriteLine($"Dockerfile written to '{this.OutputPath}'.");
}
}
@ -165,7 +165,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
{
if (!this.supportedRuntimePlatforms.Contains(this.RuntimePlatformName))
{
console.WriteLine($"WARNING: Unable to find provided runtime platform name '{this.RuntimePlatformName}' in " +
_ = console.WriteLine($"WARNING: Unable to find provided runtime platform name '{this.RuntimePlatformName}' in " +
$"supported list of runtime platform names: {string.Join(", ", this.supportedRuntimePlatforms)}. " +
$"The provided runtime platform name will be used in case this Dockerfile command or image is outdated.");
}
@ -207,7 +207,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
// We first add IConfiguration to DI so that option services like
// `DotNetCoreScriptGeneratorOptionsSetup` services can get it through DI and read from the config
// and set the options.
services
_ = services
.AddSingleton<IConfiguration>(config)
.AddOptionsServices()
.Configure<BuildScriptGeneratorOptions>(options =>

Просмотреть файл

@ -37,7 +37,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
var opts = serviceProvider.GetRequiredService<IOptions<BuildScriptGeneratorOptions>>().Value;
var beginningOutputLog = GetBeginningCommandOutputLog();
console.WriteLine(beginningOutputLog);
_ = console.WriteLine(beginningOutputLog);
if (string.IsNullOrWhiteSpace(this.Command))
{
@ -69,14 +69,14 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
detectedPlatforms);
if (!string.IsNullOrEmpty(installationScript))
{
scriptBuilder.AddCommand(installationScript);
_ = scriptBuilder.AddCommand(installationScript);
}
scriptBuilder.Source(
_ = scriptBuilder.Source(
$"{FilePaths.Benv} " +
$"{string.Join(" ", detectedPlatforms.Select(p => $"{p.Platform}={p.PlatformVersion}"))}");
scriptBuilder
_ = scriptBuilder
.AddCommand("echo Executing supplied command...")
.AddCommand(this.Command);
@ -86,21 +86,21 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
var tempScriptPath = Path.Combine(tempDirectoryProvider.GetTempDirectory(), "execCommand.sh");
var script = scriptBuilder.ToString();
File.WriteAllText(tempScriptPath, script);
console.WriteLine("Finished generating script.");
_ = console.WriteLine("Finished generating script.");
timedEvent.AddProperty(nameof(tempScriptPath), tempScriptPath);
if (this.DebugMode)
{
console.WriteLine($"Temporary script @ {tempScriptPath}:");
console.WriteLine("---");
console.WriteLine(script);
console.WriteLine("---");
_ = console.WriteLine($"Temporary script @ {tempScriptPath}:");
_ = console.WriteLine("---");
_ = console.WriteLine(script);
_ = console.WriteLine("---");
}
console.WriteLine();
console.WriteLine("Executing generated script...");
console.WriteLine();
_ = console.WriteLine();
_ = console.WriteLine("Executing generated script...");
_ = console.WriteLine();
exitCode = ProcessHelper.RunProcess(
shellPath,
@ -110,7 +110,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
{
if (args.Data != null)
{
console.WriteLine(args.Data);
_ = console.WriteLine(args.Data);
}
},
(sender, args) =>
@ -154,7 +154,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
// We first add IConfiguration to DI so that option services like
// `DotNetCoreScriptGeneratorOptionsSetup` services can get it through DI and read from the config
// and set the options.
services
_ = services
.AddSingleton<IConfiguration>(config)
.AddOptionsServices()
.Configure<BuildScriptGeneratorOptions>(options =>

Просмотреть файл

@ -62,7 +62,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
}
}
console.WriteLine(this.OutputJson ? JsonConvert.SerializeObject(platformInfo) : FormatResult(platformInfo));
_ = console.WriteLine(this.OutputJson ? JsonConvert.SerializeObject(platformInfo) : FormatResult(platformInfo));
return ProcessConstants.ExitSuccess;
}
@ -83,7 +83,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
// We first add IConfiguration to DI so that option services like
// `DotNetCoreScriptGeneratorOptionsSetup` services can get it through DI and read from the config
// and set the options.
services
_ = services
.AddSingleton<IConfiguration>(config)
.AddOptionsServices();
});
@ -98,23 +98,23 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
foreach (PlatformResult platform in platforms)
{
var defs = new DefinitionListFormatter();
defs.AddDefinition("Platform", platform.Name);
_ = defs.AddDefinition("Platform", platform.Name);
defs.AddDefinition(
_ = defs.AddDefinition(
"Versions",
(platform.Versions != null && platform.Versions.Any()) ?
string.Join(Environment.NewLine, platform.Versions) : "N/A");
if (platform.Properties != null && platform.Properties.Any())
{
defs.AddDefinition(
_ = defs.AddDefinition(
"Properties",
string.Join(
Environment.NewLine,
platform.Properties.Select(prop => $"{prop.Key} - {prop.Value}")));
}
result.AppendLine(defs.ToString());
_ = result.AppendLine(defs.ToString());
}
return result.ToString();

Просмотреть файл

@ -151,7 +151,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
var options = serviceProvider.GetRequiredService<IOptions<BuildScriptGeneratorOptions>>().Value;
var beginningOutputLog = GetBeginningCommandOutputLog();
console.WriteLine(beginningOutputLog);
_ = console.WriteLine(beginningOutputLog);
int exitCode;
using (var timedEvent = logger.LogTimedEvent("EnvSetupCommand"))
@ -161,7 +161,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
IEnumerable<PlatformDetectorResult> detectedPlatforms = null;
if (this.SkipDetection)
{
console.WriteLine(
_ = console.WriteLine(
$"Skipping platform detection since '{SkipDetectionTemplate}' switch was used...");
var platforms = serviceProvider.GetRequiredService<IEnumerable<IProgrammingPlatform>>();
@ -204,7 +204,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
if (!string.IsNullOrEmpty(snippet))
{
scriptBuilder
_ = scriptBuilder
.AppendLine("echo")
.AppendLine("echo Setting up environment...")
.AppendLine("echo")
@ -224,10 +224,10 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
if (this.DebugMode)
{
console.WriteLine($"Temporary script @ {tempScriptPath}:");
console.WriteLine("---");
console.WriteLine(scriptBuilder);
console.WriteLine("---");
_ = console.WriteLine($"Temporary script @ {tempScriptPath}:");
_ = console.WriteLine("---");
_ = console.WriteLine(scriptBuilder);
_ = console.WriteLine("---");
}
var environment = serviceProvider.GetRequiredService<IEnvironment>();
@ -241,7 +241,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
{
if (args.Data != null)
{
console.WriteLine(args.Data);
_ = console.WriteLine(args.Data);
}
},
(sender, args) =>
@ -279,7 +279,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
// Gather all the values supplied by the user in command line
this.SourceDir = string.IsNullOrEmpty(this.SourceDir) ?
Directory.GetCurrentDirectory() : Path.GetFullPath(this.SourceDir);
configBuilder.AddIniFile(Path.Combine(this.SourceDir, Constants.BuildEnvironmentFileName), optional: true);
_ = configBuilder.AddIniFile(Path.Combine(this.SourceDir, Constants.BuildEnvironmentFileName), optional: true);
}
else
{
@ -302,10 +302,10 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
versionsFilePath);
}
configBuilder.AddIniFile(versionsFilePath, optional: false);
_ = configBuilder.AddIniFile(versionsFilePath, optional: false);
}
configBuilder
_ = configBuilder
.AddEnvironmentVariables()
.Add(GetCommandLineConfigSource());
@ -320,7 +320,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
// We first add IConfiguration to DI so that option services like
// `DotNetCoreScriptGeneratorOptionsSetup` services can get it through DI and read from the config
// and set the options.
services
_ = services
.AddSingleton<IConfiguration>(config)
.AddOptionsServices()
.Configure<BuildScriptGeneratorOptions>(options =>

Просмотреть файл

@ -16,7 +16,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
[Command(
Name,
Description = "Generate startup script for an app.",
ThrowOnUnexpectedArgument = false,
UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.StopParsingAndCollect,
AllowArgumentSeparator = true)]
internal class RunScriptCommand : CommandBase
{
@ -69,15 +69,15 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
if (string.IsNullOrWhiteSpace(this.OutputPath))
{
console.WriteLine(script);
_ = console.WriteLine(script);
}
else
{
File.WriteAllText(this.OutputPath, script);
console.WriteLine($"Script written to '{this.OutputPath}'");
_ = console.WriteLine($"Script written to '{this.OutputPath}'");
// Try making the script executable
ProcessHelper.TrySetExecutableMode(this.OutputPath);
_ = ProcessHelper.TrySetExecutableMode(this.OutputPath);
}
return ProcessConstants.ExitSuccess;

Просмотреть файл

@ -61,7 +61,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
var version = GetVersion();
var commit = GetMetadataValue(GitCommit);
var releaseTagName = GetMetadataValue(ReleaseTagName);
console.WriteLine($"Version: {version}, Commit: {commit}, ReleaseTagName: {releaseTagName}");
_ = console.WriteLine($"Version: {version}, Commit: {commit}, ReleaseTagName: {releaseTagName}");
return ProcessConstants.ExitSuccess;
}

Просмотреть файл

@ -30,13 +30,13 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
LogManager.ReconfigExistingLoggers();
this.serviceCollection = new ServiceCollection();
this.serviceCollection
_ = this.serviceCollection
.AddBuildScriptGeneratorServices()
.AddCliServices(console)
.AddLogging(builder =>
{
builder.SetMinimumLevel(Extensions.Logging.LogLevel.Trace);
builder.AddNLog(new NLogProviderOptions
_ = builder.SetMinimumLevel(Extensions.Logging.LogLevel.Trace);
_ = builder.AddNLog(new NLogProviderOptions
{
CaptureMessageTemplates = true,
CaptureMessageProperties = true,
@ -52,7 +52,7 @@ namespace Microsoft.Oryx.BuildScriptGeneratorCli
public ServiceProviderBuilder ConfigureScriptGenerationOptions(Action<BuildScriptGeneratorOptions> configure)
{
this.serviceCollection.Configure<BuildScriptGeneratorOptions>(opts => configure(opts));
_ = this.serviceCollection.Configure<BuildScriptGeneratorOptions>(opts => configure(opts));
return this;
}

Просмотреть файл

@ -53,7 +53,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator
// Stop a running measurement
var span = this.endings[marker];
this.events.GetValueOrDefault(span)?.Dispose(); // Records the measurement
this.events.Remove(span); // No need to check if the removal succeeded, because the event might not exist
_ = this.events.Remove(span); // No need to check if the removal succeeded, because the event might not exist
}
}
}

Просмотреть файл

@ -14,12 +14,20 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JsonFlatFileDataStore" Version="2.2.3" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.3.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="JsonFlatFileDataStore" Version="2.4.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="RunProcessAsTask" Version="1.2.4" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.4.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.7" />
</ItemGroup>
</Project>

Просмотреть файл

@ -19,7 +19,7 @@ namespace Microsoft.Oryx.BuildServer
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
_ = webBuilder.UseStartup<Startup>();
});
}
}

Просмотреть файл

@ -29,7 +29,7 @@ namespace Microsoft.Oryx.BuildServer.Services.ArtifactBuilders
var outputPath = this.ValidateParameter($"{build.OutputPath}/{build.Id}");
var platform = this.ValidateParameter(build.Platform);
var version = this.ValidateParameter(build.Version);
Directory.CreateDirectory(outputPath);
_ = Directory.CreateDirectory(outputPath);
var cmd = $"oryx build {sourcePath} --log-file {logFilePath} " +
$"--output {outputPath} --platform {platform} " +
$"--platform-version {version}";
@ -48,7 +48,7 @@ namespace Microsoft.Oryx.BuildServer.Services.ArtifactBuilders
};
try
{
process.Start();
_ = process.Start();
this.logger.LogInformation($"Process has started for command: {cmd}");
var outputHandler = new FileOutputHandler(new StreamWriter(logFilePath), this.logger);
process.OutputDataReceived += outputHandler.Handle;

Просмотреть файл

@ -14,7 +14,7 @@ namespace Microsoft.Oryx.BuildServer.Services
{
public void RunInBackground(IArtifactBuilder builder, Build build, Callback successCallback, Callback failureCallback)
{
var t = Task.Run(() =>
_ = Task.Run(() =>
{
try
{

Просмотреть файл

@ -26,7 +26,7 @@ namespace Microsoft.Oryx.BuildServer.Services
public async Task<Build> StartBuildAsync(Build build)
{
build.Status = "IN_PROGRESS";
await this.buildRepository.InsertAsync(build);
_ = await this.buildRepository.InsertAsync(build);
var artifactBuilder = this.artifactBuilderFactory.CreateArtifactBuilder(build);
this.buildRunner.RunInBackground(artifactBuilder, build, this.MarkCompletedAsync, this.MarkFailedAsync);
return build;
@ -43,21 +43,21 @@ namespace Microsoft.Oryx.BuildServer.Services
public async Task<Build> MarkCancelledAsync(Build build)
{
build.Status = "CANCELLED";
await this.buildRepository.UpdateAsync(build);
_ = await this.buildRepository.UpdateAsync(build);
return build;
}
public async Task<Build> MarkCompletedAsync(Build build)
{
build.Status = "COMPLETED";
await this.buildRepository.UpdateAsync(build);
_ = await this.buildRepository.UpdateAsync(build);
return build;
}
public async Task<Build> MarkFailedAsync(Build build)
{
build.Status = "FAILED";
await this.buildRepository.UpdateAsync(build);
_ = await this.buildRepository.UpdateAsync(build);
return build;
}
}

Просмотреть файл

@ -34,21 +34,21 @@ namespace Microsoft.Oryx.BuildServer
string folderName = "/store";
if (!Directory.Exists(folderName))
{
Directory.CreateDirectory(folderName);
_ = Directory.CreateDirectory(folderName);
}
var store = new DataStore("/store/builds.json", keyProperty: "id");
services.AddHttpContextAccessor();
services.AddMvc();
services.AddSingleton<IRepository>(x => new BuildRepository(store));
services.AddScoped<IArtifactBuilder, ArtifactBuilder>();
services.AddScoped<IArtifactBuilderFactory, ArtifactBuilderFactory>();
services.AddScoped<IBuildRunner, BuildRunner>();
services.AddScoped<IBuildService, BuildService>();
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddSingleton<ILoggerFactory, LoggerFactory>();
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
services.AddControllers();
_ = services.AddHttpContextAccessor();
_ = services.AddMvc();
_ = services.AddSingleton<IRepository>(x => new BuildRepository(store));
_ = services.AddScoped<IArtifactBuilder, ArtifactBuilder>();
_ = services.AddScoped<IArtifactBuilderFactory, ArtifactBuilderFactory>();
_ = services.AddScoped<IBuildRunner, BuildRunner>();
_ = services.AddScoped<IBuildService, BuildService>();
_ = services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
_ = services.AddSingleton<ILoggerFactory, LoggerFactory>();
_ = services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
_ = services.AddControllers();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -56,16 +56,16 @@ namespace Microsoft.Oryx.BuildServer
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
_ = app.UseDeveloperExceptionPage();
}
app.UseRouting();
_ = app.UseRouting();
app.UseAuthorization();
_ = app.UseAuthorization();
app.UseEndpoints(endpoints =>
_ = app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
_ = endpoints.MapDefaultControllerRoute();
});
}
}

Просмотреть файл

@ -34,7 +34,7 @@
<Rule Id="VSTHRD002" Action="None" /> <!-- Use await or JoinableTaskFactory.Run instead -->
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.FxCopAnalyzers" RuleNamespace="Microsoft.CodeAnalysis.FxCopAnalyzers">
<Rules AnalyzerId="Microsoft.CodeAnalysis.NetAnalyzers" RuleNamespace="Microsoft.CodeAnalysis.NetAnalyzers">
<!-- "Do not declare static members on generic types" -->
<Rule Id="CA1000" Action="Info" />

Просмотреть файл

@ -55,10 +55,10 @@
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SemanticVersioning" Version="1.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="SemanticVersioning" Version="2.0.2" />
<PackageReference Include="xunit" Version="2.4.2" />
</ItemGroup>
<ItemGroup>
@ -85,4 +85,12 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.4.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.7" />
</ItemGroup>
</Project>

Просмотреть файл

@ -14,19 +14,19 @@ namespace Microsoft.Oryx.Detector
{
public static IServiceCollection AddDotNetCoreServices(this IServiceCollection services)
{
services.AddSingleton<DotNetCoreDetector>();
_ = services.AddSingleton<DotNetCoreDetector>();
// Factory to make sure same detector instance is returned when same implementation type is resolved via
// multiple inteface types.
Func<IServiceProvider, DotNetCoreDetector> factory = (sp) => sp.GetRequiredService<DotNetCoreDetector>();
services.AddSingleton<IDotNetCorePlatformDetector, DotNetCoreDetector>(factory);
_ = services.AddSingleton<IDotNetCorePlatformDetector, DotNetCoreDetector>(factory);
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPlatformDetector, DotNetCoreDetector>(factory));
// Note that the order of these project file providers is important. For example, if a user explicitly
// specifies a project file using either the 'PROJECT' environment or the 'project' build property, we want
// to use that. In that case we want the ExplicitProjectFileProvider to return the project file and not
// probe for files.
services.AddSingleton<DefaultProjectFileProvider>();
_ = services.AddSingleton<DefaultProjectFileProvider>();
services.TryAddEnumerable(
ServiceDescriptor.Singleton<IProjectFileProvider, ExplicitProjectFileProvider>());
services.TryAddEnumerable(

Просмотреть файл

@ -14,12 +14,12 @@ namespace Microsoft.Oryx.Detector
{
public static IServiceCollection AddGolangServices(this IServiceCollection services)
{
services.AddSingleton<GolangDetector>();
_ = services.AddSingleton<GolangDetector>();
// Factory to make sure same detector instance is returned when same implementation type is resolved via
// multiple inteface types.
Func<IServiceProvider, GolangDetector> factory = (sp) => sp.GetRequiredService<GolangDetector>();
services.AddSingleton<IGolangPlatformDetector, GolangDetector>(factory);
_ = services.AddSingleton<IGolangPlatformDetector, GolangDetector>(factory);
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPlatformDetector, GolangDetector>(factory));
return services;
}

Просмотреть файл

@ -14,12 +14,12 @@ namespace Microsoft.Oryx.Detector
{
public static IServiceCollection AddHugoServices(this IServiceCollection services)
{
services.AddSingleton<HugoDetector>();
_ = services.AddSingleton<HugoDetector>();
// Factory to make sure same detector instance is returned when same implementation type is resolved via
// multiple inteface types.
Func<IServiceProvider, HugoDetector> factory = (sp) => sp.GetRequiredService<HugoDetector>();
services.AddSingleton<IHugoPlatformDetector, HugoDetector>(factory);
_ = services.AddSingleton<IHugoPlatformDetector, HugoDetector>(factory);
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPlatformDetector, HugoDetector>(factory));
return services;
}

Просмотреть файл

@ -14,12 +14,12 @@ namespace Microsoft.Oryx.Detector
{
public static IServiceCollection AddJavaServices(this IServiceCollection services)
{
services.AddSingleton<JavaDetector>();
_ = services.AddSingleton<JavaDetector>();
// Factory to make sure same detector instance is returned when same implementation type is resolved via
// multiple inteface types.
Func<IServiceProvider, JavaDetector> factory = (sp) => sp.GetRequiredService<JavaDetector>();
services.AddSingleton<IJavaPlatformDetector, JavaDetector>(factory);
_ = services.AddSingleton<IJavaPlatformDetector, JavaDetector>(factory);
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPlatformDetector, JavaDetector>(factory));
return services;
}

Просмотреть файл

@ -255,7 +255,7 @@ namespace Microsoft.Oryx.Detector.Node
FrameworkVersion = dependency.Value.Value,
};
detectedFrameworkResult.Add(frameworkInfo);
frameworksSet.Add(frameworkName);
_ = frameworksSet.Add(frameworkName);
}
}
@ -284,7 +284,7 @@ namespace Microsoft.Oryx.Detector.Node
FrameworkVersion = dependency.Value.Value,
};
detectedFrameworkResult.Add(frameworkInfo);
frameworksSet.Add(frameworkName);
_ = frameworksSet.Add(frameworkName);
}
}
@ -301,13 +301,13 @@ namespace Microsoft.Oryx.Detector.Node
// remove base frameworks if derived framework exists
if (frameworksSet.Contains("Gatsby") || frameworksSet.Contains("Next.js"))
{
detectedFrameworkResult.RemoveAll(x => x.Framework == "Angular");
detectedFrameworkResult.RemoveAll(x => x.Framework == "React");
_ = detectedFrameworkResult.RemoveAll(x => x.Framework == "Angular");
_ = detectedFrameworkResult.RemoveAll(x => x.Framework == "React");
}
if (frameworksSet.Contains("VuePress") || frameworksSet.Contains("Nuxt.js"))
{
detectedFrameworkResult.RemoveAll(x => x.Framework == "Vue.js");
_ = detectedFrameworkResult.RemoveAll(x => x.Framework == "Vue.js");
}
return detectedFrameworkResult;

Просмотреть файл

@ -14,12 +14,12 @@ namespace Microsoft.Oryx.Detector
{
public static IServiceCollection AddNodeServices(this IServiceCollection services)
{
services.AddSingleton<NodeDetector>();
_ = services.AddSingleton<NodeDetector>();
// Factory to make sure same detector instance is returned when same implementation type is resolved via
// multiple inteface types.
Func<IServiceProvider, NodeDetector> factory = (sp) => sp.GetRequiredService<NodeDetector>();
services.AddSingleton<INodePlatformDetector, NodeDetector>(factory);
_ = services.AddSingleton<INodePlatformDetector, NodeDetector>(factory);
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPlatformDetector, NodeDetector>(factory));
return services;
}

Просмотреть файл

@ -14,12 +14,12 @@ namespace Microsoft.Oryx.Detector
{
public static IServiceCollection AddPhpServices(this IServiceCollection services)
{
services.AddSingleton<PhpDetector>();
_ = services.AddSingleton<PhpDetector>();
// Factory to make sure same detector instance is returned when same implementation type is resolved via
// multiple inteface types.
Func<IServiceProvider, PhpDetector> factory = (sp) => sp.GetRequiredService<PhpDetector>();
services.AddSingleton<IPhpPlatformDetector, PhpDetector>(factory);
_ = services.AddSingleton<IPhpPlatformDetector, PhpDetector>(factory);
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPlatformDetector, PhpDetector>(factory));
return services;
}

Просмотреть файл

@ -19,9 +19,9 @@ namespace Microsoft.Oryx.Detector
/// <returns>An instance of <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddPlatformDetectorServices(this IServiceCollection services)
{
services.AddSingleton<IDetector, DefaultPlatformDetector>();
_ = services.AddSingleton<IDetector, DefaultPlatformDetector>();
services
_ = services
.AddLogging()
.AddOptions()
.AddDotNetCoreServices()

Просмотреть файл

@ -14,12 +14,12 @@ namespace Microsoft.Oryx.Detector
{
public static IServiceCollection AddPythonServices(this IServiceCollection services)
{
services.AddSingleton<PythonDetector>();
_ = services.AddSingleton<PythonDetector>();
// Factory to make sure same detector instance is returned when same implementation type is resolved via
// multiple inteface types.
Func<IServiceProvider, PythonDetector> factory = (sp) => sp.GetRequiredService<PythonDetector>();
services.AddSingleton<IPythonPlatformDetector, PythonDetector>(factory);
_ = services.AddSingleton<IPythonPlatformDetector, PythonDetector>(factory);
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPlatformDetector, PythonDetector>(factory));
return services;
}

Просмотреть файл

@ -14,12 +14,12 @@ namespace Microsoft.Oryx.Detector
{
public static IServiceCollection AddRubyServices(this IServiceCollection services)
{
services.AddSingleton<RubyDetector>();
_ = services.AddSingleton<RubyDetector>();
// Factory to make sure same detector instance is returned when same implementation type is resolved via
// multiple inteface types.
Func<IServiceProvider, RubyDetector> factory = (sp) => sp.GetRequiredService<RubyDetector>();
services.AddSingleton<IRubyPlatformDetector, RubyDetector>(factory);
_ = services.AddSingleton<IRubyPlatformDetector, RubyDetector>(factory);
services.TryAddEnumerable(ServiceDescriptor.Singleton<IPlatformDetector, RubyDetector>(factory));
return services;
}

Просмотреть файл

@ -17,9 +17,17 @@
<Import Project="$(MSBuildThisFileDirectory)\..\CommonFiles\AssemblyVersion.proj" />
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Tomlyn" Version="0.1.2" />
<PackageReference Include="YamlDotNet" Version="9.1.4" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
<PackageReference Include="Tomlyn" Version="0.16.2" />
<PackageReference Include="YamlDotNet" Version="12.3.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.4.33">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="SmartAnalyzers.CSharpExtensions.Annotations" Version="4.2.7" />
</ItemGroup>
</Project>

Просмотреть файл

@ -48,12 +48,12 @@ namespace Microsoft.Oryx.Common.Extensions
foreach (Match m in matches)
{
var uig = m.Groups["userinfo"];
result.Append(str.Substring(positionInStr, uig.Index - positionInStr));
result.Append(UrlUserInfoReplacement);
_ = result.Append(str.Substring(positionInStr, uig.Index - positionInStr));
_ = result.Append(UrlUserInfoReplacement);
positionInStr = uig.Index + uig.Length; // Skip past password
}
result.Append(str.Substring(positionInStr));
_ = result.Append(str.Substring(positionInStr));
return result.ToString();
}
catch
@ -98,7 +98,7 @@ namespace Microsoft.Oryx.Common.Extensions
var result = new StringBuilder();
foreach (var x in bytes)
{
result.AppendFormat("{0:x2}", x);
_ = result.AppendFormat("{0:x2}", x);
}
return result.ToString();

Просмотреть файл

@ -11,9 +11,9 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

Просмотреть файл

@ -239,7 +239,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Common.Tests
var imageHelper = new ImageTestHelper(_output, imageBaseValue, tagSuffixValue);
// Assert
Assert.Throws<NotSupportedException>(() => { imageHelper.GetBuildImage("invalidTag"); });
_ = Assert.Throws<NotSupportedException>(() => { _ = imageHelper.GetBuildImage("invalidTag"); });
}
[Fact]

Просмотреть файл

@ -40,7 +40,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Common.Tests
public void VersionInfo_InvalidDisplayVersion_ThrowsArgumentException(string displayVersion)
{
// Assert
Assert.Throws<ArgumentException>(() => { new VersionInfo(displayVersion); });
_ = Assert.Throws<ArgumentException>(() => { _ = new VersionInfo(displayVersion); });
}
[Theory]

Просмотреть файл

@ -16,15 +16,16 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="Moq" Version="4.10.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="Moq" Version="4.18.4" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="XunitXml.TestLogger" Version="2.1.26" />
<PackageReference Include="XunitXml.TestLogger" Version="3.0.70" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

Просмотреть файл

@ -547,7 +547,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests
generator.GenerateBashScript(context, out var generatedScript, messages);
// Assert
Assert.Single(messages);
_ = Assert.Single(messages);
Assert.Equal(repoWarning, messages.First());
}

Просмотреть файл

@ -18,17 +18,17 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests
{
// Arrange
var platform1 = new Mock<IProgrammingPlatform>();
platform1
_ = platform1
.Setup(p => p.Detect(It.IsAny<RepositoryContext>()))
.Returns(new PlatformDetectorResult { Platform = "platform1", PlatformVersion = "1.0.0" });
platform1
_ = platform1
.Setup(p => p.IsEnabled(It.IsAny<RepositoryContext>()))
.Returns(true);
var platform2 = new Mock<IProgrammingPlatform>();
platform2
_ = platform2
.Setup(p => p.Detect(It.IsAny<RepositoryContext>()))
.Returns(new PlatformDetectorResult { Platform = "platform2", PlatformVersion = "1.0.0" });
platform2
_ = platform2
.Setup(p => p.IsEnabled(It.IsAny<RepositoryContext>()))
.Returns(true);
var detector = CreatePlatformDetector(new[] { platform1.Object, platform2.Object });
@ -52,17 +52,17 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests
{
// Arrange
var platform1 = new Mock<IProgrammingPlatform>();
platform1
_ = platform1
.Setup(p => p.Detect(It.IsAny<RepositoryContext>()))
.Returns(new PlatformDetectorResult { Platform = "platform1", PlatformVersion = "1.0.0" });
platform1
_ = platform1
.Setup(p => p.IsEnabled(It.IsAny<RepositoryContext>()))
.Returns(true);
var platform2 = new Mock<IProgrammingPlatform>();
platform2
_ = platform2
.Setup(p => p.Detect(It.IsAny<RepositoryContext>()))
.Returns(new PlatformDetectorResult { Platform = "platform2", PlatformVersion = "1.0.0" });
platform2
_ = platform2
.Setup(p => p.IsEnabled(It.IsAny<RepositoryContext>()))
.Returns(false);
var detector = CreatePlatformDetector(new[] { platform1.Object, platform2.Object });
@ -83,17 +83,17 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests
{
// Arrange
var platform1 = new Mock<IProgrammingPlatform>();
platform1
_ = platform1
.Setup(p => p.Detect(It.IsAny<RepositoryContext>()))
.Returns(value: null);
platform1
_ = platform1
.Setup(p => p.IsEnabled(It.IsAny<RepositoryContext>()))
.Returns(true);
var platform2 = new Mock<IProgrammingPlatform>();
platform2
_ = platform2
.Setup(p => p.Detect(It.IsAny<RepositoryContext>()))
.Returns(new PlatformDetectorResult { Platform = "platform2", PlatformVersion = "1.0.0" });
platform2
_ = platform2
.Setup(p => p.IsEnabled(It.IsAny<RepositoryContext>()))
.Returns(true);
var detector = CreatePlatformDetector(new[] { platform1.Object, platform2.Object });

Просмотреть файл

@ -27,7 +27,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Node
};
// Act & Assert
Assert.Single(NodePackageScriptsChecker.CheckScriptsForGlobalInstallationAttempts(scripts));
_ = Assert.Single(NodePackageScriptsChecker.CheckScriptsForGlobalInstallationAttempts(scripts));
}
[Theory]

Просмотреть файл

@ -27,7 +27,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Node
new Dictionary<string, string> { { NodeConstants.NodeToolName, "1.0.0" } });
// Assert
Assert.Single(messages);
_ = Assert.Single(messages);
Assert.Contains("outdated version of node was detected", messages.First().Content);
}

Просмотреть файл

@ -463,7 +463,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Php
detectedVersion: detectedVersion,
defaultVersion: detectedDefaultVersion,
phpScriptGeneratorOptions: options,
supportedPhpVersions: new[] { detectedVersion, detectedDefaultVersion, envVarDefaultVersion }.Where(x => !x.IsNullOrEmpty()).ToArray());
supportedPhpVersions: new[] { detectedVersion, detectedDefaultVersion, envVarDefaultVersion }.Where(x => !string.IsNullOrEmpty(x)).ToArray());
// Act
var result = platform.Detect(context);

Просмотреть файл

@ -363,7 +363,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
detectedVersion: detectedVersion,
defaultVersion: detectedDefaultVersion,
pythonScriptGeneratorOptions: options,
supportedVersions: new[] { detectedVersion, detectedDefaultVersion, envVarDefaultVersion }.Where(x => !x.IsNullOrEmpty()).ToArray());
supportedVersions: new[] { detectedVersion, detectedDefaultVersion, envVarDefaultVersion }.Where(x => !string.IsNullOrEmpty(x)).ToArray());
// Act
var result = platform.Detect(context);

Просмотреть файл

@ -25,7 +25,7 @@ namespace Microsoft.Oryx.BuildScriptGenerator.Tests.Python
new Dictionary<string, string> { { PythonConstants.PlatformName, PythonVersions.Python27Version } });
// Assert
Assert.Single(messages);
_ = Assert.Single(messages);
Assert.Contains("outdated version of python was detected", messages.First().Content);
}

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше