Skip to content

Commit

Permalink
Merge pull request #7476 from dotnet/dev/v-wuzhai/Fix-error-xUnit1012
Browse files Browse the repository at this point in the history
Fix error Xunit1012
  • Loading branch information
MiYanni authored Jan 19, 2024
2 parents 74d4a78 + 0e4a840 commit c0176c3
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 70 deletions.
8 changes: 4 additions & 4 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
</Dependency>
</ProductDependencies>
<ToolsetDependencies>
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.24065.5">
<Dependency Name="Microsoft.DotNet.Arcade.Sdk" Version="9.0.0-beta.24066.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>0d95a90310e5e2afbef31f4ca1c4b692698cd686</Sha>
<Sha>d5ee27a55ec6383c29790f3ec666e7c87f7da022</Sha>
<SourceBuild RepoName="arcade" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="9.0.0-beta.24065.5">
<Dependency Name="Microsoft.DotNet.XliffTasks" Version="9.0.0-beta.24066.3">
<Uri>https://github.com/dotnet/arcade</Uri>
<Sha>0d95a90310e5e2afbef31f4ca1c4b692698cd686</Sha>
<Sha>d5ee27a55ec6383c29790f3ec666e7c87f7da022</Sha>
</Dependency>
</ToolsetDependencies>
</Dependencies>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
}
},
"msbuild-sdks": {
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24065.5"
"Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24066.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ internal class JoinMacroConfig : BaseMacroConfig<JoinMacro, JoinMacroConfig>, IM
private const string SymbolsTypePropertyName = "type";
private const string SymbolsValuePropertyName = "value";

internal JoinMacroConfig(JoinMacro macro, string variableName, string? dataType, IReadOnlyList<(JoinType, string)> symbols, string separator = "", bool removeEmptyValues = false)
internal JoinMacroConfig(JoinMacro macro, string variableName, string? dataType, IReadOnlyList<(JoinType, string)> symbols, string? separator = "", bool removeEmptyValues = false)
: base(macro, variableName, dataType)
{
Symbols = symbols ?? throw new ArgumentNullException(nameof(symbols));
Separator = separator;
Separator = separator ?? string.Empty;
RemoveEmptyValues = removeEmptyValues;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.TemplateEngine.Utils/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ static Microsoft.TemplateEngine.Utils.TemplateParameterExtensions.IsValidMultiVa
static Microsoft.TemplateEngine.Utils.TemplateParameterExtensions.TokenizeMultiValueParameter(this string! literal) -> System.Collections.Generic.IReadOnlyList<string!>!
override Microsoft.TemplateEngine.Utils.RangeVersionSpecification.ToString() -> string!
static Microsoft.TemplateEngine.Utils.Timing.Over(Microsoft.Extensions.Logging.ILogger! logger, string! label) -> Microsoft.TemplateEngine.Utils.Timing!
static Microsoft.TemplateEngine.Utils.VersionStringHelpers.CompareVersions(string! version1, string! version2) -> int?
static Microsoft.TemplateEngine.Utils.VersionStringHelpers.IsVersionWellFormed(string! version) -> bool
static Microsoft.TemplateEngine.Utils.VersionStringHelpers.CompareVersions(string? version1, string? version2) -> int?
static Microsoft.TemplateEngine.Utils.VersionStringHelpers.IsVersionWellFormed(string? version) -> bool
static Microsoft.TemplateEngine.Utils.VersionStringHelpers.TryParseVersionSpecification(string! versionString, out Microsoft.TemplateEngine.Utils.IVersionSpecification? specification) -> bool
static Microsoft.TemplateEngine.Utils.WellKnownSearchFilters.AuthorFilter(string? author) -> System.Func<Microsoft.TemplateEngine.Abstractions.ITemplateInfo!, Microsoft.TemplateEngine.Abstractions.TemplateFiltering.MatchInfo?>!
static Microsoft.TemplateEngine.Utils.WellKnownSearchFilters.BaselineFilter(string? baselineName) -> System.Func<Microsoft.TemplateEngine.Abstractions.ITemplateInfo!, Microsoft.TemplateEngine.Abstractions.TemplateFiltering.MatchInfo?>!
Expand Down
20 changes: 12 additions & 8 deletions src/Microsoft.TemplateEngine.Utils/VersionStringHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static bool TryParseVersionSpecification(string versionString, out IVersi
// -1 if version1 < version2
// 0 if version1 == version2
// 1 if version1 > version2
public static int? CompareVersions(string version1, string version2)
public static int? CompareVersions(string? version1, string? version2)
{
if (!TryParseVersionString(version1, out int[]? parts1) || !TryParseVersionString(version2, out int[]? parts2))
{
Expand All @@ -49,32 +49,36 @@ public static bool TryParseVersionSpecification(string versionString, out IVersi
return 0;
}

public static bool IsVersionWellFormed(string version)
public static bool IsVersionWellFormed(string? version)
{
return TryParseVersionString(version, out _);
}

// tries to parse a version into 4 int parts, zero-padding on the right if needed.
// more than 4 parts, return false.
// Not parse-able, return false.
private static bool TryParseVersionString(string version, out int[]? parsed)
private static bool TryParseVersionString(string? version, out int[]? parsed)
{
if (string.IsNullOrEmpty(version))
{
parsed = null;
return false;
}

string[] parts = version.Split(new[] { '.' });
if (parts.Length is < 2 or > 4)
string[]? parts = version?.Split(new[] { '.' });

if (parts != null)
{
parsed = null;
return false;
if (parts.Length is < 2 or > 4)
{
parsed = null;
return false;
}
}

parsed = new[] { 0, 0, 0, 0 };

for (int i = 0; i < parts.Length; i++)
for (int i = 0; i < parts?.Length; i++)
{
if (int.TryParse(parts[i], out int intPart))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public TemplateEngineSamplesTest(ITestOutputHelper log)
public async void TemplateEngineSamplesProjectTest(
string folderName,
string shortName,
string[] args,
string[]? args,
string caseDescription)
{
_log.LogInformation($"Template with {caseDescription}");
Expand All @@ -65,7 +65,7 @@ public async void TemplateEngineSamplesProjectTest(

private string GetSamplesTemplateLocation() => Path.Combine(CodeBaseRoot, "dotnet-template-samples", "content");

private (Dictionary<string, string?> Args, string ArgsScenarioName) GetTemplateArgs(string[] args)
private (Dictionary<string, string?> Args, string ArgsScenarioName) GetTemplateArgs(string[]? args)
{
var templateArgs = new Dictionary<string, string?>();
StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TokenTrieTests
[InlineData("Hello There!", 1, 1, false, "Hello", " ", null)]
[InlineData("Hello There!", 5, 6, true, null, " ", "There!")]
[InlineData("Hello There!", 0, 6, true, "Hello", " ", "There!")]
public void VerifyTokenTrieLookArounds(string original, int checkPosition, int expectedPosition, bool success, string after, string value, string before)
public void VerifyTokenTrieLookArounds(string original, int checkPosition, int expectedPosition, bool success, string? after, string value, string? before)
{
byte[] data = Encoding.UTF8.GetBytes(original);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public LocalizationTests(EnvironmentSettingsHelper environmentSettingsHelper)
[InlineData(null, "name")]
[InlineData("de-DE", "name_de-DE:äÄßöÖüÜ")]
[InlineData("tr-TR", "name_tr-TR:çÇğĞıIİöÖşŞüÜ")]
public void TestLocalizedTemplateName(string locale, string expectedName)
public void TestLocalizedTemplateName(string? locale, string expectedName)
{
_ = LoadHostWithLocalizationTemplates(locale, out _, out ITemplateInfo localizationTemplate);

Expand All @@ -35,7 +35,7 @@ public void TestLocalizedTemplateName(string locale, string expectedName)
[InlineData(null, "desc")]
[InlineData("de-DE", "desc_de-DE:äÄßöÖüÜ")]
[InlineData("tr-TR", "desc_tr-TR:çÇğĞıIİöÖşŞüÜ")]
public void TestLocalizedTemplateDescription(string locale, string expectedDescription)
public void TestLocalizedTemplateDescription(string? locale, string expectedDescription)
{
_ = LoadHostWithLocalizationTemplates(locale, out _, out ITemplateInfo localizationTemplate);

Expand All @@ -46,7 +46,7 @@ public void TestLocalizedTemplateDescription(string locale, string expectedDescr
[InlineData(null, "someSymbol", "sym0_displayName")]
[InlineData("de-DE", "someSymbol", "sym0_displayName_de-DE:äÄßöÖüÜ")]
[InlineData("tr-TR", "someSymbol", "sym0_displayName_tr-TR:çÇğĞıIİöÖşŞüÜ")]
public void TestLocalizedSymbolDisplayName(string locale, string symbolName, string expectedDisplayName)
public void TestLocalizedSymbolDisplayName(string? locale, string symbolName, string expectedDisplayName)
{
_ = LoadHostWithLocalizationTemplates(locale, out _, out ITemplateInfo localizationTemplate);

Expand All @@ -59,7 +59,7 @@ public void TestLocalizedSymbolDisplayName(string locale, string symbolName, str
[InlineData(null, "someChoice", "sym1_displayName")]
[InlineData("de-DE", "someChoice", "sym1_displayName")]
[InlineData("tr-TR", "someChoice", "sym1_displayName_tr-TR:çÇğĞıIİöÖşŞüÜ")]
public void TestLocalizedSymbolChoiceDisplayName(string locale, string symbolName, string expectedDisplayName)
public void TestLocalizedSymbolChoiceDisplayName(string? locale, string symbolName, string expectedDisplayName)
{
_ = LoadHostWithLocalizationTemplates(locale, out _, out ITemplateInfo localizationTemplate);

Expand All @@ -72,7 +72,7 @@ public void TestLocalizedSymbolChoiceDisplayName(string locale, string symbolNam
[InlineData(null, "sym0_desc")]
[InlineData("de-DE", "sym0_desc_de-DE:äÄßöÖüÜ")]
[InlineData("tr-TR", "sym0_desc_tr-TR:çÇğĞıIİöÖşŞüÜ")]
public void TestLocalizedSymbolDescription(string locale, string expectedDescription)
public void TestLocalizedSymbolDescription(string? locale, string expectedDescription)
{
_ = LoadHostWithLocalizationTemplates(locale, out _, out ITemplateInfo localizationTemplate);

Expand All @@ -86,7 +86,7 @@ public void TestLocalizedSymbolDescription(string locale, string expectedDescrip
[InlineData("de-DE", "sym1_desc_de-DE:äÄßöÖüÜ", "sym1_choice0_de-DE:äÄßöÖüÜ", "sym1_choice1_de-DE:äÄßöÖüÜ", "sym1_choice2")]
[InlineData("tr-TR", "sym1_desc_tr-TR:çÇğĞıIİöÖşŞüÜ", "sym1_choice0_tr-TR:çÇğĞıIİöÖşŞüÜ", "sym1_choice1", "sym1_choice2_tr-TR:çÇğĞıIİöÖşŞüÜ")]
public void TestLocalizedSymbolChoices(
string locale,
string? locale,
string symbolDesc,
string choice0Desc,
string choice1Desc,
Expand Down Expand Up @@ -117,7 +117,7 @@ public void TestLocalizedSymbolChoices(
[InlineData(1, "tr-TR", "pa1_desc_tr-TR:çÇğĞıIİöÖşŞüÜ", "pa1_manualInstructions0_tr-TR:çÇğĞıIİöÖşŞüÜ")]
public async Task TestLocalizedPostActionFields(
int postActionIndex,
string locale,
string? locale,
string expectedDescription,
string expectedManualInstructions)
{
Expand Down Expand Up @@ -156,7 +156,7 @@ public void TestLocaleCountryFallback(string locale, string expectedName)
Assert.Equal(expectedName, localizationTemplate.Name);
}

private IEngineEnvironmentSettings LoadHostWithLocalizationTemplates(string locale, out TemplatePackageManager templatePackageManager, out ITemplateInfo localizationTemplate)
private IEngineEnvironmentSettings LoadHostWithLocalizationTemplates(string? locale, out TemplatePackageManager templatePackageManager, out ITemplateInfo localizationTemplate)
{
var builtins = BuiltInTemplatePackagesProviderFactory.GetComponents(GetTestTemplateLocation("TemplateWithLocalization"));
var env = _environmentSettingsHelper.CreateEnvironment(locale: locale, additionalComponents: builtins);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class NuGetVersionHelperTests
[InlineData("*.1", false)]
[InlineData("a.b", false)]
[InlineData("a.b.*", false)]
public void IsSupportedVersionStringTest(string versionString, bool isSupported)
public void IsSupportedVersionStringTest(string? versionString, bool isSupported)
{
Assert.Equal(isSupported, NuGetVersionHelper.IsSupportedVersionString(versionString));
}
Expand All @@ -37,7 +37,7 @@ public void IsSupportedVersionStringTest(string versionString, bool isSupported)
[InlineData("55.66.77*", true)]
[InlineData("123.456.789.012", false)]
[InlineData("1.2", false)]
public void TryParseFloatRangeReturnsExpectedBoolFlag(string versionString, bool isFloatingVersion)
public void TryParseFloatRangeReturnsExpectedBoolFlag(string? versionString, bool isFloatingVersion)
{
Assert.Equal(isFloatingVersion, NuGetVersionHelper.TryParseFloatRangeEx(versionString, out _));
}
Expand All @@ -48,7 +48,7 @@ public void TryParseFloatRangeReturnsExpectedBoolFlag(string versionString, bool
[InlineData("1.2.3.4", "1.2.*", true)]
[InlineData("1.2.3.4", "2.2*", false)]
[InlineData("1.2.3.4", "1.2.*-*", true)]
public void TryParseFloatRangeMatchingTest(string versionString, string pattern, bool isMatch)
public void TryParseFloatRangeMatchingTest(string versionString, string? pattern, bool isMatch)
{
NuGetVersion version = new NuGetVersion(versionString);
Assert.True(NuGetVersionHelper.TryParseFloatRangeEx(pattern, out FloatRange floatRange));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ await InstantiateAsyncHelper(
[InlineData(null, false, null, "", false, null)]
[InlineData(false, false, false, "", false, null)]
[InlineData(true, false, true, "A,C", false, null)]
public async void InstantiateAsync_ConditionalParametersIsRequiredEvaluation(bool? a_val, bool? b_val, bool? c_val, string expectedOutput, bool instantiateShouldFail, string expectedErrorMessage)
public async void InstantiateAsync_ConditionalParametersIsRequiredEvaluation(bool? a_val, bool? b_val, bool? c_val, string expectedOutput, bool instantiateShouldFail, string? expectedErrorMessage)
{
//
// Template content preparation
Expand Down Expand Up @@ -377,7 +377,7 @@ public async void InstantiateAsync_ConditionalParametersRequiredOverwrittenByDis
string? b,
string expectedOutput,
bool instantiateShouldFail,
string expectedErrorMessage)
string? expectedErrorMessage)
{
//
// Template content preparation
Expand Down Expand Up @@ -449,7 +449,7 @@ public async void InstantiateAsync_ConditionalParametersInversedEnablingConditio
bool? a,
string expectedOutput,
bool instantiateShouldFail,
string expectedErrorMessage)
string? expectedErrorMessage)
{
//
// Template content preparation
Expand Down Expand Up @@ -549,7 +549,7 @@ public async void InstantiateAsync_ConditionalParametersEvaluationBehavior(
string paramSnippet,
string expectedOutput,
bool instantiateShouldFail,
string expectedErrorMessage)
string? expectedErrorMessage)
{
//
// Template content preparation
Expand Down Expand Up @@ -875,7 +875,7 @@ private async Task InstantiateAsyncHelper(
string templateSnippet,
string sourceSnippet,
string expectedOutput,
string expectedErrorMessage,
string? expectedErrorMessage,
bool instantiateShouldFail,
string? name = "sourceFile",
string expectedOutputName = "./sourceFile.cs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public JoinMacroTests(EnvironmentSettingsHelper environmentSettingsHelper)
[InlineData(",", false)]
[InlineData("", false)]
[InlineData(null, false)]
public void TestJoinConstantAndReferenceSymbolConfig(string separator, bool removeEmptyValues)
public void TestJoinConstantAndReferenceSymbolConfig(string? separator, bool removeEmptyValues)
{
string variableName = "joinedParameter";
string referenceSymbolName = "referenceSymbol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void GeneratedSymbolTest()
[InlineData("", "string")]
[InlineData("string", "string")]
[InlineData("date", "date")]
public void EvaluateNowOverrideDatatypeInConfig(string type, string expectedType)
public void EvaluateNowOverrideDatatypeInConfig(string? type, string expectedType)
{
string variableName = "nowString";
string format = string.Empty;
Expand Down
Loading

0 comments on commit c0176c3

Please sign in to comment.