-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f0b87d
commit acbd60f
Showing
6 changed files
with
114 additions
and
56 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
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,47 @@ | ||
// 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.Diagnostics.CodeAnalysis; | ||
|
||
namespace System.CommandLine.Parsing; | ||
|
||
/// <summary> | ||
/// Provides a description of a <see cref="CliDiagnostic"/>. | ||
/// </summary> | ||
public sealed class CliDiagnosticDescriptor | ||
{ | ||
public CliDiagnosticDescriptor(string id, string title, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string messageFormat, CliDiagnosticSeverity severity, string? helpUri) | ||
{ | ||
Id = id; | ||
Title = title; | ||
MessageFormat = messageFormat; | ||
Severity = severity; | ||
HelpUri = helpUri; | ||
} | ||
|
||
/// <summary> | ||
/// A unique identifier for the diagnostic. | ||
/// </summary> | ||
public string Id { get; } | ||
|
||
/// <summary> | ||
/// A short title describing the diagnostic. | ||
/// </summary> | ||
public string Title { get; } | ||
|
||
/// <summary> | ||
/// A composite format string, which can be passed to <see cref="string.Format(string, object[])"/> to create a message. | ||
/// </summary> | ||
[StringSyntax(StringSyntaxAttribute.CompositeFormat)] | ||
public string MessageFormat { get; } | ||
|
||
/// <summary> | ||
/// The severity of the diagnostic. | ||
/// </summary> | ||
public CliDiagnosticSeverity Severity { get; } | ||
|
||
/// <summary> | ||
/// An optional hyperlink that provides more information about the diagnostic. | ||
/// </summary> | ||
public string? HelpUri { get; } | ||
} |
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,31 @@ | ||
// 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. | ||
|
||
namespace System.CommandLine.Parsing; | ||
|
||
/// <summary> | ||
/// Describes how severe a <see cref="CliDiagnostic"/> is."/> | ||
/// </summary> | ||
// Pattern based on: https://github.com/dotnet/roslyn/blob/1cca63b5d8ea170f8d8e88e1574aa3ebe354c23b/src/Compilers/Core/Portable/Diagnostic/DiagnosticSeverity.cs. | ||
public enum CliDiagnosticSeverity | ||
{ | ||
/// <summary> | ||
/// Something that is not surfaced through normal means. | ||
/// </summary> | ||
Hidden = 0, | ||
|
||
/// <summary> | ||
/// Information that does not indicate a problem (i.e. not prescriptive). | ||
/// </summary> | ||
Info, | ||
|
||
/// <summary> | ||
/// Something suspicious but allowed. | ||
/// </summary> | ||
Warning, | ||
|
||
/// <summary> | ||
/// Something that is definitely wrong and needs fixing. | ||
/// </summary> | ||
Error | ||
} |
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,17 @@ | ||
// 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. | ||
|
||
namespace System.CommandLine.Parsing; | ||
|
||
internal static class ParseDiagnostics | ||
{ | ||
public const string DirectiveIsNotDefinedId = "CMD0001"; | ||
public static readonly CliDiagnosticDescriptor DirectiveIsNotDefined = | ||
new( | ||
DirectiveIsNotDefinedId, | ||
//TODO: use localized strings | ||
"Directive is not defined", | ||
"The directive '{0}' is not defined.", | ||
CliDiagnosticSeverity.Error, | ||
null); | ||
} |
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