Fomoxa.Attributes 0.1.0

dotnet add package Fomoxa.Attributes --version 0.1.0
                    
NuGet\Install-Package Fomoxa.Attributes -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fomoxa.Attributes" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Fomoxa.Attributes" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Fomoxa.Attributes" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Fomoxa.Attributes --version 0.1.0
                    
#r "nuget: Fomoxa.Attributes, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Fomoxa.Attributes@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Fomoxa.Attributes&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Fomoxa.Attributes&version=0.1.0
                    
Install as a Cake Tool

fomoxa-attributes (C#)

The official Fomoxa attributes for C#: [Network] and [Codec].

fomoxa-attributes  →  your source  →  fomoxac  →  generated code

Two attributes, in the Fomoxa namespace, and nothing else. This package is the syntax half of Fomoxa — the part that makes annotated C# carry the metadata fomoxac reads.

The one rule

Fomoxa wire types are defined by the Fomoxa Specification, not by the host programming language.

Native C# types do not determine the Fomoxa byte representation.

[Network("u32")]
public uint Id { get; set; }
u32 the Fomoxa wire type — 4 bytes, Little Endian, per the Specification
uint the C# representation — how your program happens to store it

The wire format always comes from the Specification. Change the C# type and nothing on the wire moves:

[Network("u32")] public uint  Id { get; set; }   // 4 bytes LE
[Network("u32")] public ulong Id { get; set; }   // still 4 bytes LE

Both are u32, because u32 says so. Whether a ulong is a sensible place to keep one is a question for the code generator and the C# compiler — it is not a question about the wire, and this package never asks it.

Usage

using Fomoxa;

[Network]
[Codec("edge", "unity")]
public class DeviceState
{
    [Network("u32")]
    [Codec("edge", "unity")]
    public uint Id { get; set; }

    [Network("f32")]
    [Codec("edge")]
    public float Temperature { get; set; }

    [Network("string")]
    [Codec("unity")]
    public string DisplayName { get; set; } = string.Empty;
}
Where Attribute Says
model [Network] this type is a Fomoxa network model
model [Codec("edge", "unity")] generate these codecs for it
field [Network("u32")] this field's Fomoxa wire type
field [Codec("edge")] which of the model's codecs this field appears in

From the model above, fomoxac knows to generate:

DeviceStateEdgeCodec    →  Id, Temperature
DeviceStateUnityCodec   →  Id, DisplayName

Fields and properties both work, and a model may be a class or a struct.

Codec names are yours

edge, unity, orange_pi, database, custom_protocol — this package has never heard of any of them, holds no list of them, and gives none of them meaning. They are identifiers you invent; fomoxac uses them to spell the type it generates. The repeated form and the list form are the same thing:

[Codec("edge", "unity")]      // ==  [Codec("edge")]
                              //     [Codec("unity")]

Order is preserved.

Why a string, and not typeof

[Network(typeof(uint))]     // ← not this
[Network("u32")]            // ← this

typeof(uint) would make the host language the source of truth, and it is not. Fomoxa defines u32 as four bytes Little Endian for every language; C# defines uint as whatever it likes. Deriving one from the other is how an implementation ends up unable to decode what another implementation wrote:

Fomoxa Specification          C# Type
        │ defines                 │ guess
        ▼                         ▼
   Wire Type                 Wire Type          ← wrong
        │                         │ guess
        ▼                         ▼
  Byte Layout                Byte Layout        ← wrong, and silently
        │
   ┌────┼────┐
   ▼    ▼    ▼
 Rust   C#   Go
   └── same bytes ──┘

So the string is stored exactly as written and is never interpreted here. There is no list of valid wire types in this assembly, no mapping from C# types, and no opinion about byte layout. fomoxac reads the string and resolves it against the Specification.

What this package does not contain

Everything else.

  • No runtime. No Writer, no Reader, no buffer.
  • No encode, no decode. No serialization of any kind.
  • No byte layout. No endian conversion, no IEEE conversion, no string encoding, no array encoding, no length prefixes.
  • No type mapping. Nothing anywhere says typeof(uint) → "u32".
  • No schema, no IR, no compiler, no registry, no reflection system.
  • No dependencies.

The public surface is two types, both attributes, and there is a test that fails if that ever stops being true.

A note on wire type spelling

RFC-0001 §1 lists the scalars lowercase — bool, i8, u32, f32 — and the composites capitalised: String, Bytes, Array<T>, Struct, Enum. The examples in this package's brief use lowercase "string".

This package does not resolve that. It stores what you write, byte for byte, and hands it back unchanged. Which spelling is canonical is a question for the Specification and for fomoxac, and inventing an answer here — a validator, an alias table, a normaliser — would be inventing a wire format. TODO: settle the spelling in the Specification, then fomoxac enforces it.

Layout

fomoxa-attributes-csharp/
├── Fomoxa.Attributes.csproj
├── src/
│   ├── NetworkAttribute.cs
│   └── CodecAttribute.cs
├── tests/
└── README.md

There is no NetworkFieldAttribute.cs. In C#, [Network("u32")] resolves to a class named NetworkAttribute, so the model marker and the field wire type must be the same class with two constructors — a second class would have to be spelled [NetworkField("u32")], which is not the syntax.

Tests

Metadata only, because metadata is all there is. Model detection, wire type extraction, model-level and field-level codecs, multiple codecs and their order, and the case the brief names explicitly:

[Network("u32")]
public ulong Value { get; set; }   // wire type is still "u32"

Plus two tests that guard the scope: the assembly exports exactly Fomoxa.NetworkAttribute and Fomoxa.CodecAttribute, and every exported type is an attribute.

dotnet test tests/Fomoxa.Attributes.Tests

Build

dotnet build
dotnet pack -c Release

Targets netstandard2.0, so it can be referenced from .NET Framework, .NET 8, Unity and Godot alike.

License

Apache-2.0

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 313 8/23/2026