Files
sbox-public/engine/Sandbox.System/CodeGen/CodeGeneratorAttribute.cs
Garry Newman 8488a42896 Misc fixes 2205 (#4906)
* Fix CodeGeneratorAttribute not setting priority
* Fix Color32.Write not writing a
* Logger correctly writes exceptions in Info/Trace
* Fix QRectF float truncation
* Fix parsing error in Phrase
* Fix exception in Widget.IsActiveWindow
* Don't try to unlock achievements on the dedicated server
* Don't try to CopyFrom an invalid texture
* Component.Invoke doesn't throw exception when CancellationToken is cancelled, just returns silently
* LobbyQuery.Request returns empty if no SteamMatchmaking pointer
* Fix not capturing achievement unlock exception properly
* Fix NRE in DisconnectScope
* LobbyQuery.RequestAsync returns an empty array instead of null if query fucked up
2026-05-22 12:16:07 +01:00

50 lines
2.0 KiB
C#

namespace Sandbox;
/// <summary>
/// An attribute that can be added to a custom <see cref="Attribute"/> class for special code generation behavior.
/// They'll then be applied to methods and properties when they are decorated with <i>that</i> attribute.
/// </summary>
[AttributeUsage( AttributeTargets.Class, AllowMultiple = true )]
public class CodeGeneratorAttribute : Attribute
{
/// <summary>
/// Attributes with a higher priority will wrap the target first. The default priority is 0.
/// </summary>
public int Priority { get; init; } = 0;
/// <summary>
/// The name of the callback method. This can be a fully qualified static method callback or a simple callback to invoke
/// on the target object if the method or property target is not static.
/// </summary>
public string CallbackName { get; init; }
/// <summary>
/// The type of code generation you want to do.
/// You will need to specify whether it should apply to instance or static methods and properties using the <see cref="CodeGeneratorFlags.Instance"/>
/// and <see cref="CodeGeneratorFlags.Static"/> flags.
/// </summary>
public CodeGeneratorFlags Type { get; init; }
/// <summary>
/// Perform code generation for a method or property.
/// </summary>
/// <param name="type">
/// The type of code generation you want to do.
/// You will need to specify whether it should apply to instance or static methods and properties using the <see cref="CodeGeneratorFlags.Instance"/>
/// and <see cref="CodeGeneratorFlags.Static"/> flags.
/// </param>
/// <param name="callbackName">
/// The name of the callback method. This can be a fully qualified static method callback or a simple callback to invoke
/// on the target object if the method or property target is not static.
/// </param>
/// <param name="priority">
/// Attributes with a higher priority will wrap the target first. The default priority is 0.
/// </param>
public CodeGeneratorAttribute( CodeGeneratorFlags type, string callbackName, int priority = 0 )
{
CallbackName = callbackName;
Priority = priority;
Type = type;
}
}