Attribute Reference

Transpose's code-generation attributes live in the Transpose namespace (a few Web-binding markers live in Transpose.Core), so a single using Transpose; brings them into scope.

This page lists every attribute the compiler special-cases, with its status. An attribute the compiler does not read is inert: it compiles, it appears in reflection metadata, and it changes nothing about the emitted JavaScript.

Status Meaning
Implemented The compiler acts on it.
No-op by design Transpose's default behaviour already produces the effect, so the attribute is redundant.
Not implemented A recognised gap versus h5; currently ignored.

Interoperability

[External] — Implemented

Marks a type or member as defined in native JavaScript. No body is emitted, the member binds to its JavaScript name (camelCased by default), and it is excluded from reflection metadata and interface registration. A plain indexer on an external type becomes native bracket access.

Can be applied to a whole assembly with [assembly: External], which is how the binding libraries are built.

[External]
public class ExistingJsLibrary { }

[Name("jsName")] — Implemented

Overrides the emitted JavaScript name of a type or member. The name is used verbatim and is never given an overload suffix. A dotted value ([Name("tss.IC")]) also fixes the mangled interface-slot prefix and overrides enum member string names.

[Name("myCustomName")]
public void MyMethod() { }

[Namespace(...)] — Implemented

Overrides the emitted namespace of a type.

  • [Namespace("My.Custom.Namespace")] replaces the C# namespace.
  • [Namespace(false)] (or [Namespace("")]) suppresses the namespace, so the type binds to its bare name — this is how Transpose.Core's primitive bindings (String, Number, Object, …) map onto the JavaScript globals.
  • [Namespace(true)] is the default.
[Namespace("My.Custom.Namespace")]
public class MyClass { }

[Namespace(false)]
public class GlobalClass { }

[Template("…")] — Implemented

A JavaScript expression that replaces the member's call site entirely. Supports {this}, {0}, {1} … and {parameterName} substitution. A templated member is inlined, excluded from overload numbering, keeps its raw name, and does not thread type arguments.

[Template("console.log({0})")]
public static extern void Log(object message);

[Script("…")] — Implemented

Supplies a raw JavaScript body for a method, accessor or operator; the C# body, if any, is discarded. This is what lets an extern member be implemented in hand-written JavaScript. Pass several strings for several lines.

[Script("alert('Hello');")]
public void Alert() { }

[GlobalMethods] — Implemented

A static class whose members are projected onto the JavaScript global scope, so the type name disappears from the call (alert(…) rather than Type.alert(…)). Equivalent to an empty-prefix [Scope].

[Scope("prefix")] — Implemented

(Defined in Transpose.Core.) Projects a type's static members and nested types onto an ambient JavaScript binding — dom.window.foo emits as window.foo. Scoped types are treated as external for naming and excluded from interface registration and reflection.

[GlobalTarget("name")] — Implemented

Marks a method as a typed window onto a JavaScript global: the call is replaced by that global's name. An empty name compiles the call away entirely, which is the "force a reference" marker pattern the binding libraries use.

[ExpandParams] — Implemented

A params method so marked has its trailing array spread as individual arguments at the call site, for a variadic JavaScript or DOM function.

[AccessorsIndexer] — Implemented

Forces an external type's indexer to route through getItem/setItem accessors instead of native bracket access.

[Convention(Notation, …)] — Implemented

Sets the JavaScript name casing (None / lower / upper / camel / Pascal) for the members of an external or BCL type, with per-member-kind and priority resolution. Used to author binding libraries; not useful in application code.

[ObjectLiteral] — Implemented

Emits a class or struct as a plain JavaScript object rather than a runtime type instance. new produces an object literal. See JSON Serialization.

[ObjectLiteral]
public class Options { public int Id { get; set; } }

Initialization

[Ready] — Implemented

A static method so marked is registered to run when the DOM is ready — or immediately if the document has already loaded. Registrations are emitted after every type in the bundle is defined.

[Ready]
public static void OnReady() { }

[Init] — Not implemented

h5 emitted a static method's body at a chosen position in the file (Top / Before / After / Bottom of the class) as an initializer. Transpose does not read it. Use the standard .NET [ModuleInitializer], which Transpose collects and calls ahead of the entry point — see App Initialization.


Enums and reflection

[Enum(Emit.…)] — Implemented (all nine modes)

Selects how an enum and its members are emitted.

Emit value Backing Member's JavaScript name / value default(E)
Name numeric named member, case preserved (Dir.TopLeft) 0
Value numeric the reference inlines the ordinal (0) 0
StringName string the name, camelCased ("topLeft") the zero member's string
StringNamePreserveCase string the name, case preserved ("TopLeft") the zero member's string
StringNameLowerCase string the name, lowercased ("topleft") the zero member's string
StringNameUpperCase string the name, uppercased ("TOPLEFT") the zero member's string
NamePreserveCase (default) numeric named member, case preserved 0
NameLowerCase numeric named member, lowercased (Dir.topleft) 0
NameUpperCase numeric named member, uppercased (Dir.TOPLEFT) 0
[Enum(Emit.StringName)]
public enum Color { Red, Green }

Notes:

  • The default with no [Enum] is NamePreserveCase. Name and NamePreserveCase are equivalent.
  • The string modes back the enum with strings: the type declares its underlying type as System.String, so x === "red" comparisons work from JavaScript. The member's JavaScript key stays verbatim; only the string value is cased.
  • The name modes keep numeric ordinals; the casing applies to the member's JavaScript name, so it also governs ToString() and Enum.GetName.
  • An explicit [Name("…")] on a member overrides the mode's casing for that member.

[Reflectable(...)] — Implemented

Overrides the default reflection policy for one type or member. [Reflectable(false)] excludes it from the emitted metadata; [Reflectable(true)] (or no argument) forces it in. There is no assembly-level form — use reflection.disabled in tps.json to turn metadata off project-wide. See Reflection.

[Reflectable(false)]
public class NonReflectable { }

[NonScriptable] — Implemented

Excludes a type, member or accessor from the emitted reflection metadata, and filters the code-generation attributes themselves out of reflectable-attribute lists.

[IgnoreGeneric] — Implemented

A generic method or type so marked does not thread its type arguments as leading runtime parameters at the call site. Also honoured in reflection.


Recognised .NET attributes

Attribute Effect
[Flags] The enum is emitted with the runtime's flags behaviour (bitwise ToString).
[AttributeUsage] Inherited / AllowMultiple are carried into an attribute type's reflection metadata.
[Conditional("SYM")] A call is removed entirely — arguments not evaluated — when none of the symbols is defined, matching C# semantics.
[ModuleInitializer] The method is called ahead of the entry point.
[DllImport] / [LibraryImport] / [InlineArray] Reported as unsupported features — a compile error, since P/Invoke and inline arrays have no browser equivalent.
[InternalsVisibleTo] Skipped when synthesizing assembly attributes; meaningless in emitted JavaScript.

[MethodImpl], [DebuggerHidden], [DebuggerStepThrough], [CompilerGenerated], the Nullable* family, [AsyncStateMachine] and [Extension] need no handling — Transpose simply never emits them.


No-ops by design

These exist so that h5 code compiles, and the behaviour they requested is already Transpose's default.

Attribute Why it is redundant
[IgnoreCast] Transpose already erases casts to all external (native-JavaScript) types. See Type Casting.
[Unbox(false)] Transpose never emits parameter unboxing — primitives are already native JavaScript values.
[InlineConst] Transpose always inlines const values at their use sites.
[Where(...)], [Allow(...)] Generic-constraint and permission markers; neither h5 nor Transpose reads them for code generation.

Not implemented

Present in the libraries so existing code compiles, but not read by the compiler. If your code depends on one of these, the emitted JavaScript will not reflect it.

Attribute What it did in h5
[Module], [ModuleDependency] Emit the type or assembly under a module system (AMD / CommonJS / ES6 / UMD). See Output Types.
[FileName], [Output], [OutputBy] Output file and folder layout. Partially covered by the tps.json output / outputBy settings instead.
[Cast("…")] A custom cast template. Use a [Template] method instead.
[Init(InitPosition)] Emit a static method's body as a positioned initializer. Use [ModuleInitializer].
[Mixin("expr")] Merge a type's members into a target JavaScript object or prototype.
[Constructor("…")] Supply a custom inline JavaScript constructor body.
[Field] Emit a property as a plain data field with no accessors.
[Rules(...)] Override code-generation rules (lambda / boxing / array-index / integer / anonymous-type handling).
[Optional] Add the TypeScript ? modifier — Transpose emits no TypeScript definitions.
[ToAwait] Rewrite a Task.Wait()-style call to an await and make the caller async.
[Virtual] Reference a type late-bound by name instead of by its direct global.
[ExternalInterface] Mark an interface implemented outside the Transpose type system.
[Immutable] Mark a type immutable, affecting value-type copy semantics.
[Priority(n)] Influence the emission order of types.
[PrivateProtected] A synthesized marker recording private protected accessibility for reflection.

The following markers appear on Transpose.Core types as historical artifacts and are read by neither h5 nor Transpose: [CombinedClass], [StaticInterface], [ClassInterface], [FormerInterface], [InterfaceWrapper], [GenericDefault], [ExportedAs], [Generated].


Quick reference

Attribute Status
External Implemented
Name Implemented
Namespace Implemented
Template Implemented
Script Implemented
ObjectLiteral Implemented
Enum Implemented
GlobalMethods Implemented
Scope Implemented
GlobalTarget Implemented
Reflectable Implemented
NonScriptable Implemented
ExpandParams Implemented
IgnoreGeneric Implemented
AccessorsIndexer Implemented
Convention Implemented
Ready Implemented
IgnoreCast No-op by design
Unbox No-op by design
InlineConst No-op by design
Where / Allow No-op by design
Module / ModuleDependency Not implemented
FileName / Output / OutputBy Not implemented
Cast Not implemented
Init Not implemented
Mixin Not implemented
Constructor Not implemented
Field Not implemented
Rules Not implemented
Optional Not implemented
ToAwait Not implemented
Virtual Not implemented
ExternalInterface Not implemented
Immutable Not implemented
Priority Not implemented
PrivateProtected Not implemented
© 2026 Curiosity. All rights reserved.