Javascript must be enabled to continue!
Implementing traits in C# using Roslyn Source Generators
View through CrossRef
The paper presents an approach to implementing traits functionality in the C# programming language through the use of Roslyn Source Generators, a compile-time metaprogramming tool introduced in .NET5. Traits, which are composable units of fine-grained reuse, can benefit the C# language by bringing a mechanism for behavior reuse in the context of single inheritance. The article describes the design and implementation of a source generator that allows to annotate classes with metadata attributes, automatically injecting the corresponding member definitions at compile time. To achieve better code generation performance at design time, Incremental Source Generators were used. The composition of trait members is described in detail, focusing on name conflict resolution and type safety by utilizing interfaces and the override mechanism. Defining non-public members in a context of a trait is also discussed and implemented, thus allowing for better code reusability. The article concludes that language-level features such as traits can be implemented in the C# language by using Roslyn Source Generators, thus demonstrating the potential of such an instrument and metaprogramming in general.
Title: Implementing traits in C# using Roslyn Source Generators
Description:
The paper presents an approach to implementing traits functionality in the C# programming language through the use of Roslyn Source Generators, a compile-time metaprogramming tool introduced in .
NET5.
Traits, which are composable units of fine-grained reuse, can benefit the C# language by bringing a mechanism for behavior reuse in the context of single inheritance.
The article describes the design and implementation of a source generator that allows to annotate classes with metadata attributes, automatically injecting the corresponding member definitions at compile time.
To achieve better code generation performance at design time, Incremental Source Generators were used.
The composition of trait members is described in detail, focusing on name conflict resolution and type safety by utilizing interfaces and the override mechanism.
Defining non-public members in a context of a trait is also discussed and implemented, thus allowing for better code reusability.
The article concludes that language-level features such as traits can be implemented in the C# language by using Roslyn Source Generators, thus demonstrating the potential of such an instrument and metaprogramming in general.
Related Results
AMPLITUDE METHODS FOR CONTROL OF GAS GENERATORS WATER SAVING SYSTEMS
AMPLITUDE METHODS FOR CONTROL OF GAS GENERATORS WATER SAVING SYSTEMS
The methods of control of the technical station of gas generators of systems for saving and supplying water are examined, which are based on the variation of their amplitude-freque...
Genetic study of reproductive, dairy and growth traits in Guzerá cattle
Genetic study of reproductive, dairy and growth traits in Guzerá cattle
The Guzerá breed is an important Brazilian genetic resource and has been widely used as a pure breed and in crossbreeding strategies to produce animals adapted to tropical climatic...
Personality Traits of Minority Arab Teachers in the Arab Educational System in Israel
Personality Traits of Minority Arab Teachers in the Arab Educational System in Israel
AbstractThe present research examined the personality traits prevalent among Arab teachers as a minority in the Arab educational system in Israel.Research on personality traits ha...
Genetic relationships between live animal scan traits and carcass traits of Australian Angus bulls and heifers
Genetic relationships between live animal scan traits and carcass traits of Australian Angus bulls and heifers
Genetic parameters of four ultrasound live-scan traits and five carcass traits of Australian Angus cattle were examined with regard to sex and age of the scanned individuals. Live-...
Analysis of the main effect clustering and decision-making coefficients for F2 generation of upland cotton in Southern Xinjiang
Analysis of the main effect clustering and decision-making coefficients for F2 generation of upland cotton in Southern Xinjiang
Abstract
Yield and fibre quality traits respectively accounting for 4 and 5 of their 278 varieties (lines) and their 784 F2 crosses of upland cotton were for their additive...
Condensed Aerosol Generators in Fire Safety of Buildings. Part 1 – Analysis of Normative and Legal Documents
Condensed Aerosol Generators in Fire Safety of Buildings. Part 1 – Analysis of Normative and Legal Documents
Aim: The aim of this paper is to present the construction and principle of operation of condensed aerosol generators, as well as a review of their selected characteristics, confirm...
JUGE: An infrastructure for benchmarking Java unit test generators
JUGE: An infrastructure for benchmarking Java unit test generators
SummaryResearchers and practitioners have designed and implemented various automated test case generators to support effective software testing. Such generators exist for various l...
Feasibility of using his bundle pacing with boston scientific generators
Feasibility of using his bundle pacing with boston scientific generators
Abstract
Introduction
His bundle pacing (HBP) aims to deliver physiological activation of the ventricles via the native His-Purk...

