Skip to content

Commit 5ed2ee5

Browse files
Include optional logger name in console output if it fails to load (#9288)
Include optional logger name in console output if it fails to load during initialization. Help identifying the logger that has issue Fixes #9289 --------- Co-authored-by: Rainer Sigwald <raines@microsoft.com>
1 parent 2a789cd commit 5ed2ee5

File tree

17 files changed

+66
-52
lines changed

17 files changed

+66
-52
lines changed

src/Build/Logging/LoggerDescription.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal int LoggerId
8989
/// <summary>
9090
/// This property generates the logger name by appending together the class name and assembly name
9191
/// </summary>
92-
internal string Name
92+
public string Name
9393
{
9494
get
9595
{
@@ -104,7 +104,7 @@ internal string Name
104104
}
105105
else
106106
{
107-
return _loggerAssembly.AssemblyFile;
107+
return _loggerAssembly.AssemblyFile ?? _loggerAssembly.AssemblyName;
108108
}
109109
}
110110
}

src/MSBuild.UnitTests/XMake_Tests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2484,13 +2484,13 @@ public void MultipleTargetsDoesNotCrash()
24842484
}
24852485

24862486
[Theory]
2487-
[InlineData("-logger:,\"nonExistentlogger.dll\",IsOptional;Foo")]
2488-
[InlineData("-logger:ClassA,\"nonExistentlogger.dll\",IsOptional;Foo")]
2489-
[InlineData("-logger:,\"nonExistentlogger.dll\",IsOptional,OptionB,OptionC")]
2490-
[InlineData("-distributedlogger:,\"nonExistentlogger.dll\",IsOptional;Foo")]
2491-
[InlineData("-distributedlogger:ClassA,\"nonExistentlogger.dll\",IsOptional;Foo")]
2492-
[InlineData("-distributedlogger:,\"nonExistentlogger.dll\",IsOptional,OptionB,OptionC")]
2493-
public void MissingOptionalLoggersAreIgnored(string logger)
2487+
[InlineData("-logger:,\"nonExistentlogger.dll\",IsOptional;Foo", "nonExistentLogger.dll")]
2488+
[InlineData("-logger:ClassA,\"nonExistentlogger.dll\",IsOptional;Foo", "ClassA")]
2489+
[InlineData("-logger:,\"nonExistentlogger.dll\",IsOptional,OptionB,OptionC", "nonExistentLogger.dll")]
2490+
[InlineData("-distributedlogger:,\"nonExistentlogger.dll\",IsOptional;Foo", "nonExistentLogger.dll")]
2491+
[InlineData("-distributedlogger:ClassA,\"nonExistentlogger.dll\",IsOptional;Foo", "ClassA")]
2492+
[InlineData("-distributedlogger:,\"nonExistentlogger.dll\",IsOptional,OptionB,OptionC", "nonExistentLogger.dll")]
2493+
public void MissingOptionalLoggersAreIgnored(string logger, string expectedLoggerName)
24942494
{
24952495
string projectString =
24962496
"<Project>" +
@@ -2504,7 +2504,7 @@ public void MissingOptionalLoggersAreIgnored(string logger)
25042504
var output = RunnerUtilities.ExecMSBuild(parametersLoggerOptional, out bool successfulExit, _output);
25052505
successfulExit.ShouldBe(true);
25062506
output.ShouldContain("Hello", customMessage: output);
2507-
output.ShouldContain("The specified logger could not be created and will not be used.", customMessage: output);
2507+
output.ShouldContain($"The specified logger \"{expectedLoggerName}\" could not be created and will not be used.", customMessage: output);
25082508
}
25092509

25102510
[Theory]

src/MSBuild/Resources/Strings.resx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,10 +1398,11 @@
13981398
<comment>{StrBegin="MSBUILD : error MSB1058: "}</comment>
13991399
</data>
14001400
<data name="OptionalLoggerCreationMessage" UESanitized="true" Visibility="Public">
1401-
<value>The specified logger could not be created and will not be used. {0}</value>
1401+
<value>The specified logger "{0}" could not be created and will not be used. {1}</value>
14021402
<comment>
14031403
UE: This error is shown when a logger cannot be loaded and instantiated from its assembly.
1404-
LOCALIZATION: {0} contains the exception message explaining why the
1404+
LOCALIZATION: {0} contains the logger description passed on the command line or in a
1405+
response file. {1} contains the exception message explaining why the
14051406
logger could not be created -- this message comes from the CLR/FX and is localized.
14061407
</comment>
14071408
</data>

src/MSBuild/Resources/xlf/Strings.cs.xlf

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MSBuild/Resources/xlf/Strings.de.xlf

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MSBuild/Resources/xlf/Strings.es.xlf

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MSBuild/Resources/xlf/Strings.fr.xlf

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MSBuild/Resources/xlf/Strings.it.xlf

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MSBuild/Resources/xlf/Strings.ja.xlf

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/MSBuild/Resources/xlf/Strings.ko.xlf

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)