Skip to content

Commit

Permalink
Merge pull request #7149 from dotnet/Jason/Fixes#7121
Browse files Browse the repository at this point in the history
  • Loading branch information
MiYanni authored Oct 18, 2023
2 parents 3f56ae9 + 0cbaa38 commit 9b57714
Show file tree
Hide file tree
Showing 55 changed files with 468 additions and 461 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ dotnet_diagnostic.IDE0010.severity = suggestion
dotnet_diagnostic.IDE0021.severity = suggestion
#Use expression body for methods
dotnet_diagnostic.IDE0022.severity = suggestion
#Use collection initializers
dotnet_diagnostic.IDE0028.severity = suggestion
#Use auto-implemented property
dotnet_diagnostic.IDE0032.severity = suggestion
#Use conditional expression for return
Expand All @@ -198,6 +200,12 @@ dotnet_diagnostic.IDE0160.severity = suggestion
dotnet_diagnostic.IDE0210.severity = suggestion
#Use primary constructor
dotnet_diagnostic.IDE0290.severity = suggestion
#Collection initialization can be simplified
dotnet_diagnostic.IDE0300.severity = suggestion
#Collection initialization can be simplified
dotnet_diagnostic.IDE0301.severity = suggestion
#Collection initialization can be simplified
dotnet_diagnostic.IDE0305.severity = suggestion

# License header
file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.
Expand Down
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="8.0.0-beta.23463.1">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.23510.4">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>1d451c32dda2314c721adbf8829e1c0cd4e681ff</Sha>
<Sha>0e89c8d7ddbb54510d9d0a757fda5126021b79f0</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23426.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="1.0.0-beta.23509.1" CoherentParentDependency="Microsoft.DotNet.Arcade.Sdk">
<Uri>https://github.com/dotnet/xliff-tasks</Uri>
<Sha>194f32828726c3f1f63f79f3dc09b9e99c157b11</Sha>
<Sha>4f761bf529f4be49842b13d7efcef9af87f0a973</Sha>
<SourceBuild RepoName="xliff-tasks" ManagedOnly="true" />
</Dependency>
</ToolsetDependencies>
Expand Down
2 changes: 1 addition & 1 deletion eng/common/post-build/check-channel-consistency.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ try {
. $PSScriptRoot\post-build-utils.ps1

if ($PromoteToChannels -eq "") {
Write-PipelineTaskError -Type 'warning' -Message "This build won't publish assets as it's not configured to any Maestro channel. If that wasn't intended use Darc to configure a default channel using add-default-channel for this branch or to promote it to a channel using add-build-to-channel. See https://github.com/dotnet/arcade/blob/master/Documentation/Darc.md#assigning-an-individual-build-to-a-channel for more info."
Write-PipelineTaskError -Type 'warning' -Message "This build won't publish assets as it's not configured to any Maestro channel. If that wasn't intended use Darc to configure a default channel using add-default-channel for this branch or to promote it to a channel using add-build-to-channel. See https://github.com/dotnet/arcade/blob/main/Documentation/Darc.md#assigning-an-individual-build-to-a-channel for more info."
ExitWithExitCode 0
}

Expand Down
2 changes: 1 addition & 1 deletion eng/common/sdk-task.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ try {
$GlobalJson.tools | Add-Member -Name "vs" -Value (ConvertFrom-Json "{ `"version`": `"16.5`" }") -MemberType NoteProperty
}
if( -not ($GlobalJson.tools.PSObject.Properties.Name -match "xcopy-msbuild" )) {
$GlobalJson.tools | Add-Member -Name "xcopy-msbuild" -Value "17.6.0-2" -MemberType NoteProperty
$GlobalJson.tools | Add-Member -Name "xcopy-msbuild" -Value "17.7.2-1" -MemberType NoteProperty
}
if ($GlobalJson.tools."xcopy-msbuild".Trim() -ine "none") {
$xcopyMSBuildToolsFolder = InitializeXCopyMSBuild $GlobalJson.tools."xcopy-msbuild" -install $true
Expand Down
6 changes: 3 additions & 3 deletions eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,13 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
}

# Minimum VS version to require.
$vsMinVersionReqdStr = '17.6'
$vsMinVersionReqdStr = '17.7'
$vsMinVersionReqd = [Version]::new($vsMinVersionReqdStr)

# If the version of msbuild is going to be xcopied,
# use this version. Version matches a package here:
# https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-eng/NuGet/RoslynTools.MSBuild/versions/17.6.0-2
$defaultXCopyMSBuildVersion = '17.6.0-2'
# https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-eng/NuGet/RoslynTools.MSBuild/versions/17.7.2-1
$defaultXCopyMSBuildVersion = '17.7.2-1'

if (!$vsRequirements) {
if (Get-Member -InputObject $GlobalJson.tools -Name 'vs') {
Expand Down
4 changes: 2 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"tools": {
"dotnet": "8.0.100-preview.7.23376.3",
"dotnet": "8.0.100-rc.1.23455.8",
"runtimes": {
"dotnet": [
"$(VSRedistCommonNetCoreSharedFrameworkx6480PackageVersion)"
]
}
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "8.0.0-beta.23463.1"
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.23510.4"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public async Task LocFilesAreExported()
string[] exportedFiles = await RunTemplateLocalizer(
GetTestTemplateJsonContent(),
_workingDirectory,
args: new string[] { "localize", "export", _workingDirectory })
.ConfigureAwait(false);
args: new string[] { "localize", "export", _workingDirectory });

Assert.True(exportedFiles.Length > 0);
Assert.All(exportedFiles, p =>
Expand All @@ -43,7 +42,7 @@ public async Task LocFilesAreExported()
public async Task LocFilesAreExportedFirstTime()
{
string testTemplate = GetTestTemplateInTempDir("TemplateWithSourceName");
int runResult = await Program.Main(new[] { "localize", "export", testTemplate }).ConfigureAwait(false);
int runResult = await Program.Main(new[] { "localize", "export", testTemplate });
Assert.Equal(0, runResult);
string[] exportedFiles;
string expectedExportDirectory = Path.Combine(testTemplate, ".template.config", "localize");
Expand All @@ -68,7 +67,7 @@ public async Task LocFilesAreExportedFirstTime()
public async Task EnglishLocFilesAreOverwritten()
{
string testTemplate = GetTestTemplateInTempDir("TemplateWithSourceName");
int runResult = await Program.Main(new[] { "localize", "export", testTemplate }).ConfigureAwait(false);
int runResult = await Program.Main(new[] { "localize", "export", testTemplate });
Assert.Equal(0, runResult);
string expectedExportDirectory = Path.Combine(testTemplate, ".template.config", "localize");
string enLocFile = Path.Combine(expectedExportDirectory, "templatestrings.en.json");
Expand All @@ -87,7 +86,7 @@ public async Task EnglishLocFilesAreOverwritten()
templateJsonContent.Property("author")!.Value = "New Author";
File.WriteAllText(baseConfig, templateJsonContent.ToString());

runResult = await Program.Main(new[] { "localize", "export", testTemplate }).ConfigureAwait(false);
runResult = await Program.Main(new[] { "localize", "export", testTemplate });
Assert.Equal(0, runResult);
Assert.True(File.Exists(enLocFile));
Assert.True(File.Exists(deLocFile));
Expand All @@ -106,7 +105,7 @@ public async Task TemplateLanguageLocFilesAreOverwritten()
templateJsonContent.AddFirst(new JProperty("authoringLanguage", "de"));
File.WriteAllText(baseConfig, templateJsonContent.ToString());

int runResult = await Program.Main(new[] { "localize", "export", testTemplate }).ConfigureAwait(false);
int runResult = await Program.Main(new[] { "localize", "export", testTemplate });
Assert.Equal(0, runResult);
string expectedExportDirectory = Path.Combine(testTemplate, ".template.config", "localize");
string enLocFile = Path.Combine(expectedExportDirectory, "templatestrings.en.json");
Expand All @@ -124,7 +123,7 @@ public async Task TemplateLanguageLocFilesAreOverwritten()
templateJsonContent.Property("author")!.Value = "New Author";
File.WriteAllText(baseConfig, templateJsonContent.ToString());

runResult = await Program.Main(new[] { "localize", "export", testTemplate }).ConfigureAwait(false);
runResult = await Program.Main(new[] { "localize", "export", testTemplate });
Assert.Equal(0, runResult);
Assert.True(File.Exists(enLocFile));
Assert.True(File.Exists(deLocFile));
Expand All @@ -140,8 +139,7 @@ public async Task LocFilesAreNotExportedWithDryRun()
string[] exportedFiles = await RunTemplateLocalizer(
GetTestTemplateJsonContent(),
_workingDirectory,
args: new string[] { "localize", "export", _workingDirectory, "--dry-run" })
.ConfigureAwait(false);
args: new string[] { "localize", "export", _workingDirectory, "--dry-run" });

Assert.Empty(exportedFiles);
}
Expand All @@ -152,8 +150,7 @@ public async Task LanguagesCanBeOverriden()
string[] exportedFiles = await RunTemplateLocalizer(
GetTestTemplateJsonContent(),
_workingDirectory,
args: new string[] { "localize", "export", _workingDirectory, "--language", "tr", "de" })
.ConfigureAwait(false);
args: new string[] { "localize", "export", _workingDirectory, "--language", "tr", "de" });

Assert.Equal(2, exportedFiles.Length);
Assert.True(File.Exists(Path.Combine(_workingDirectory, "localize", "templatestrings.tr.json")));
Expand All @@ -168,10 +165,10 @@ public async Task SubdirectoriesAreNotSearchedByDefault()
Directory.CreateDirectory(Path.Combine(_workingDirectory, "subdir2"));

string templateJson = GetTestTemplateJsonContent();
await File.WriteAllTextAsync(Path.Combine(_workingDirectory, "subdir", "template.json"), templateJson).ConfigureAwait(false);
await File.WriteAllTextAsync(Path.Combine(_workingDirectory, "subdir2", "template.json"), templateJson).ConfigureAwait(false);
await File.WriteAllTextAsync(Path.Combine(_workingDirectory, "subdir", "template.json"), templateJson);
await File.WriteAllTextAsync(Path.Combine(_workingDirectory, "subdir2", "template.json"), templateJson);

int runResult = await Program.Main(new string[] { "localize", "export", _workingDirectory, "--language", "es" }).ConfigureAwait(false);
int runResult = await Program.Main(new string[] { "localize", "export", _workingDirectory, "--language", "es" });
// Error: no templates found under the given folder.
Assert.NotEqual(0, runResult);

Expand All @@ -186,10 +183,10 @@ public async Task SubdirectoriesCanBeSearched()
Directory.CreateDirectory(Path.Combine(_workingDirectory, ".template.config"));

string templateJson = GetTestTemplateJsonContent();
await File.WriteAllTextAsync(Path.Combine(_workingDirectory, "subdir", ".template.config", "template.json"), templateJson).ConfigureAwait(false);
await File.WriteAllTextAsync(Path.Combine(_workingDirectory, ".template.config", "template.json"), templateJson).ConfigureAwait(false);
await File.WriteAllTextAsync(Path.Combine(_workingDirectory, "subdir", ".template.config", "template.json"), templateJson);
await File.WriteAllTextAsync(Path.Combine(_workingDirectory, ".template.config", "template.json"), templateJson);

int runResult = await Program.Main(new string[] { "localize", "export", _workingDirectory, "--language", "es", "--recursive" }).ConfigureAwait(false);
int runResult = await Program.Main(new string[] { "localize", "export", _workingDirectory, "--language", "es", "--recursive" });
Assert.Equal(0, runResult);

Assert.True(File.Exists(Path.Combine(_workingDirectory, "subdir", ".template.config", "localize", "templatestrings.es.json")));
Expand All @@ -201,9 +198,9 @@ public async Task SubdirectoriesWithoutTemplateConfigFileAreNotSearched()
{
Directory.CreateDirectory(Path.Combine(_workingDirectory, "subdir"));

await File.WriteAllTextAsync(Path.Combine(_workingDirectory, "subdir", "template.json"), GetTestTemplateJsonContent()).ConfigureAwait(false);
await File.WriteAllTextAsync(Path.Combine(_workingDirectory, "subdir", "template.json"), GetTestTemplateJsonContent());

int runResult = await Program.Main(new string[] { "localize", "export", _workingDirectory, "--language", "es", "--recursive" }).ConfigureAwait(false);
int runResult = await Program.Main(new string[] { "localize", "export", _workingDirectory, "--language", "es", "--recursive" });
// Error: no templates found under the given folder.
Assert.NotEqual(0, runResult);

Expand All @@ -217,9 +214,9 @@ public async Task SubdirectoriesWithoutTemplateConfigFileAreNotSearched()
/// </summary>
private static async Task<string[]> RunTemplateLocalizer(string jsonContent, string directory, params string[] args)
{
await File.WriteAllTextAsync(Path.Combine(directory, "template.json"), jsonContent).ConfigureAwait(false);
await File.WriteAllTextAsync(Path.Combine(directory, "template.json"), jsonContent);

int runResult = await Program.Main(args).ConfigureAwait(false);
int runResult = await Program.Main(args);
Assert.Equal(0, runResult);

string expectedExportDirectory = Path.Combine(directory, "localize");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public async void TemplateEngineSamplesProjectTest(
.AddScrubber(sb => sb.Replace(DateTime.Now.ToString("MM/dd/yyyy"), "**/**/****")));

VerificationEngine engine = new VerificationEngine(_log);
await engine.Execute(options)
.ConfigureAwait(false);
await engine.Execute(options);
}

private string GetSamplesTemplateLocation() => Path.Combine(CodeBaseRoot, "dotnet-template-samples", "content");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public async void VerificationEngine_DotFile_EditorConfigTests()

VerificationEngine engine = new VerificationEngine(_log);
// Demonstrate well handling of dot files - workarounding Verify bug https://github.com/VerifyTests/Verify/issues/699
await engine.Execute(options).ConfigureAwait(false);
await engine.Execute(options);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion test/Microsoft.TemplateEngine.Core.UnitTests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected static void Verify(Encoding encoding, Stream output, bool changed, str
string modifier = expectedChange ? string.Empty : "not ";
if (expectedChange ^ changed)
{
Assert.False(true, $"Expected value to {modifier} be changed");
Assert.Fail($"Expected value to {modifier} be changed");
}
}
}
Expand Down
Loading

0 comments on commit 9b57714

Please sign in to comment.