Skip to content

AssemblyAttributes

wwwDayDream edited this page May 9, 2024 · 4 revisions

What is an Assembly Attribute?

C# Attributes can also be applied to your assembly (what?!) and there are some specific limitations.

Restrictions

  • Assembly attributes must be outside of any namespace declarations.
  • Assembly attributes must explicitly state they are applying to the assembly with a preceeding tag assembly: inside the attribute brackets.

Examples can be seen below:

❌ Fails - Assembly Attribute Inside Namespace

using System;
using CessilCellsCeaChells.CeaChore;

namespace MyTestMod {
    [assembly: RequiresField(...)]
}

✔️ Succeeds

using System;
using CessilCellsCeaChells.CeaChore;

[assembly: RequiresField(...)]

Now you can add any of the following attributes:


Additionally, you can use the MSBuild tool to gain compile-time references to newly created members (except Enums).