// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using osu.Framework.Extensions; namespace osu.Framework.Localisation { /// /// Specifies a -based description for the target element. /// The description can be retrieved through . /// /// /// The C# language specification /// /// only permits a limited set of parameter types for attributes, /// /// and as such instances cannot be passed in directly. /// Therefore usages must pass both the target type in which the description is declared, /// as well as the name of the member which contains/returns the (using for this is strongly encouraged). /// /// /// Assuming the following source class from which the description should be returned: /// /// class Strings /// { /// public static LocalisableString Example => "example string"; /// } /// /// the attribute should be used in the following way: /// /// [LocalisableDescription(typeof(Strings), nameof(Strings.Example))] /// /// [AttributeUsage(AttributeTargets.All)] public sealed class LocalisableDescriptionAttribute : Attribute { /// /// The type declaring the static member providing the localisable description. /// public readonly Type DeclaringType; /// /// The name of the static member providing the localisable description. /// public readonly string Name; /// /// Creates a new . /// public LocalisableDescriptionAttribute(Type declaringType, string name) { DeclaringType = declaringType; Name = name; } } }