File: GeneratorDiagnostics.cs
Web Access
Project: Microsoft.DotNet.Cli.Resources.Generator.csproj (Microsoft.DotNet.Cli.Resources.Generator)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.CodeAnalysis;

namespace Microsoft.DotNet.Cli.Resources.Generator;

/// <summary>
///  Defines diagnostics reported by the resource source generator.
/// </summary>
internal static class GeneratorDiagnostics
{
    private const string Category = "Microsoft.DotNet.Cli.Resources";

    /// <summary>
    ///  Reports a resource entry whose value is not a string.
    /// </summary>
    internal static readonly DiagnosticDescriptor s_nonStringResource = new(
        id: "CLIRESX0001",
        title: "Resource entry is not a string",
        messageFormat: "Resource entry '{0}' has unsupported type '{1}' and was not generated",
        category: Category,
        defaultSeverity: DiagnosticSeverity.Warning,
        isEnabledByDefault: true);

    /// <summary>
    ///  Reports an option that the .NET CLI resource generator does not support.
    /// </summary>
    internal static readonly DiagnosticDescriptor s_unsupportedOption = new(
        id: "CLIRESX0002",
        title: "Resource generator option is not supported",
        messageFormat: "Resource file '{0}' selects unsupported option '{1}'",
        category: Category,
        defaultSeverity: DiagnosticSeverity.Error,
        isEnabledByDefault: true);

    /// <summary>
    ///  Reports a resource file that cannot be parsed or generated safely.
    /// </summary>
    internal static readonly DiagnosticDescriptor s_invalidResource = new(
        id: "CLIRESX0003",
        title: "Resource file cannot be generated",
        messageFormat: "Resource file '{0}' could not be generated: {1}",
        category: Category,
        defaultSeverity: DiagnosticSeverity.Error,
        isEnabledByDefault: true);

    /// <summary>
    ///  Reports a resource member name that conflicts with another generated member.
    /// </summary>
    internal static readonly DiagnosticDescriptor s_memberConflict = new(
        id: "CLIRESX0004",
        title: "Resource member name conflicts with another generated member",
        messageFormat: "Resource entry '{0}' maps to conflicting generated member '{1}' and was not generated",
        category: Category,
        defaultSeverity: DiagnosticSeverity.Error,
        isEnabledByDefault: true);

    /// <summary>
    ///  Reports resource files that generate the same class.
    /// </summary>
    internal static readonly DiagnosticDescriptor s_duplicateClass = new(
        id: "CLIRESX0005",
        title: "Multiple resource files generate the same class",
        messageFormat: "Resource file '{0}' generates class '{1}', which is also generated by '{2}'",
        category: Category,
        defaultSeverity: DiagnosticSeverity.Error,
        isEnabledByDefault: true);
}