forked from dotnet/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #398 from nguerrera/resx
Make all SDK errors localizable
- Loading branch information
Showing
25 changed files
with
584 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/Tasks/Microsoft.NET.Build.Tasks/BuildErrorException.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Globalization; | ||
|
||
namespace Microsoft.NET.Build.Tasks | ||
{ | ||
/// <summary> | ||
/// Represents an error that is neither avoidable in all cases nor indicative of a bug in this library. | ||
/// It will be logged as a plain build error without the exception type or stack. | ||
/// </summary> | ||
internal class BuildErrorException : Exception | ||
{ | ||
public BuildErrorException() | ||
{ | ||
} | ||
|
||
public BuildErrorException(string message) : base(message) | ||
{ | ||
} | ||
|
||
public BuildErrorException(string message, Exception innerException) : base(message, innerException) | ||
{ | ||
} | ||
|
||
public BuildErrorException(string format, params string[] args) | ||
: this(string.Format(CultureInfo.CurrentCulture, format, args)) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Microsoft.Build.Framework; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Globalization; | ||
|
||
namespace Microsoft.NET.Build.Tasks | ||
{ | ||
/// <summary> | ||
/// Provides a localizable mechanism for logging an error from the SDK targets. | ||
/// </summary> | ||
public class NETSdkError : TaskBase | ||
{ | ||
/// <summary> | ||
/// The name of the resource in Strings.resx that contains the desired error message. | ||
/// </summary> | ||
[Required] | ||
public string ResourceName { get; set; } | ||
|
||
/// <summary> | ||
/// The arguments provided to <see cref="string.Format"/> along with the retrieved resource as the format. | ||
/// </summary> | ||
public string[] FormatArguments { get; set; } | ||
|
||
protected override void ExecuteCore() | ||
{ | ||
string format = Strings.ResourceManager.GetString(ResourceName, Strings.Culture); | ||
string[] arguments = FormatArguments ?? Array.Empty<string>(); | ||
string message = string.Format(CultureInfo.CurrentCulture, format, arguments); | ||
|
||
Log.LogError(message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
src/Tasks/Microsoft.NET.Build.Tasks/ReportUserErrorException.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.