Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
IEC 17309-04 is a joint ISO/IEC standard that specifies the syntax, semantics, and core functionality of the C# programming language, with a particular focus on its integration with the .NET Framework and the Common Language Infrastructure (CLI). It serves as the fourth part of the IEC 17309 series, which defines the complete C# language specification. The scope includes lexical structure, types, expressions, statements, classes, interfaces, delegates, exceptions, attributes, generics, and conformance requirements. This standard is applicable to any implementation that aims to provide a fully conforming C# compiler and runtime environment that interoperates with the .NET ecosystem.
IEC 17309-04 defines the exact lexical grammar, including identifiers, keywords, literals, operators, and punctuators. All implementations must support Unicode source files and follow the prescribed scanning rules. The standard mandates the set of reserved keywords (e.g., class, struct, interface, delegate, enum, namespace, using, static, virtual, override) and contextual keywords (e.g., partial, yield, var, dynamic).
The standard specifies a unified type system where every value is derived from System.Object. Types are categorized as value types (structs, enumerations, primitive types) and reference types (classes, interfaces, delegates, arrays, strings). Type parameters for generics are supported, including constraints on reference types, value types, constructors, and base types.
| Type Category | Examples | Storage Location | Default Value |
|---|---|---|---|
| Value types | int, float, bool, struct, enum | Stack (typically) | 0, 0.0f, false, dynamically determined |
| Reference types | class, string, delegate, interface, array | Heap | null |
| Type parameters | T | n/a | default(T) |
IEC 17309-04 defines operator precedence and associativity for all built-in operators, including arithmetic, relational, logical, bitwise, and compound assignment. The standard introduces expression-bodied members, pattern matching expressions, and nullable value types. Statement constructs cover selection (if, switch), iteration (for, foreach, while, do), jump (break, continue, return, goto), exception handling (try, catch, finally, throw), and checked/unchecked contexts.
Conforming implementations must support custom attributes applied to assemblies, types, methods, parameters, and other targets. The standard defines a subset of intrinsic attributes (e.g., System.ObsoleteAttribute, System.CLSCompliantAttribute) and the mechanism for user-defined attributes.
Implementers of IEC 17309-04 must provide a compiler that translates C# source code into Common Intermediate Language (CIL) targeting a runtime that adheres to the Common Language Infrastructure (ISO/IEC 23271). The standard mandates deterministic semantic analysis, including overload resolution, type inference, and implicit/explicit conversions.
Enum.ToString() format pitfalls). Conforming implementations must warn on use of obsolete patterns such as new constraints without explicit constructor constraints.Versioning is a critical aspect: IEC 17309-04 defines a version-tolerance mechanism through the use of the AssemblyVersion attribute and the #pragma warning directive to handle breaking changes in referenced libraries.
Conformance to IEC 17309-04 requires passing the official test suite, which covers all mandatory language features and error diagnostics. Compliant implementations must be certified by a recognized testing body and include the standard conformance assertion in their product documentation.
All implementations must support the full Unicode specification for identifiers and character literals, as defined in the standard. Additionally, they must provide a documented way to switch between language versions for backward compatibility (e.g., /langversion compiler option).