CSharp Class

Namespace
Kampute.DocToolkit.Languages
Assembly
  • Kampute.DocToolkit.dll

Definition

Represents the C# programming language model.
public class CSharp : IProgrammingLanguage
Inheritance
Implements

Remarks

The CSharp class is a concrete implementation of the IProgrammingLanguage interface that provides formatting functionality specifically for the C# programming language. It handles the complexities of C# syntax including:
  • Rendering type and member signatures according to C# syntax conventions
  • Formatting type definitions with proper modifiers and constraints
  • Handling special C# features like operators, extension methods, and attributes
  • Properly formatting literals according to C# syntax rules
  • Providing links to official C# documentation for language keywords
This class serves as the foundation for generating properly formatted C# references in documentation, ensuring that code snippets and API references follow standard C# conventions.

The CSharp class supports customization through CodeStyleOptions to adjust the formatting style to match different coding standards and preferences.

Constructors

CSharp()Initializes a new instance of the CSharp class with default options.
CSharp(CodeStyleOptions)Initializes a new instance of the CSharp class with the specified options.

Properties

IdentifierGets the identifier used for signature highlighting of code written in the programming language.
NameGets the name of the language.
OptionsGets the options the define the behavior of the C# language when formatting code elements.

Methods

IsLanguageKeyword(string)Determines if the specified value is a C# keyword.
ToString()Returns a string that represents the name of the programming language.
TryGetKeywordUrl(string, out Uri)Attempts to get the documentation URL for a given C# keyword.
TryGetOperatorSymbol(string, out string)Attempts to get the operator symbol for a given operator name.
TryGetSimplifiedName(IType, out string)Attempts to retrieve the simplified name of a system type.
TryGetUrl(string, out Uri)Attempts to retrieves the URL to the official documentation for a specified C# keyword.
WriteAttribute(TextWriter, ICustomAttribute, NameQualifier, MemberDocLinker)Writes the specified attribute formatted according to C# syntax rules to the provided TextWriter.
WriteConstantValue(TextWriter, object, IType, MemberDocLinker)Writes a constant value formatted according to C# syntax rules to the provided TextWriter.
WriteDefinition(TextWriter, IMember, MemberDocLinker)Writes the definition of a specified member as it appears in C# code to the provided TextWriter.
WriteLiteral(TextWriter, object)Writes a literal value to the TextWriter.
WriteName(TextWriter, IMember, NameQualifier, MemberDocLinker)Writes the name of a member formatted according to C# syntax rules to the provided TextWriter.
WriteSignature(TextWriter, IMember, NameQualifier, MemberDocLinker)Writes the signature of a member formatted according to C# syntax rules to the provided TextWriter.

Extension Methods

FormatAttribute(this IProgrammingLanguage, ICustomAttribute, NameQualifier)Formats the specified custom attribute according to syntax rules of the language.
FormatCodeReference(this IProgrammingLanguage, string, Func<IMember, NameQualifier>)Formats the given code reference (cref) according to syntax rules of the language.
FormatDefinition(this IProgrammingLanguage, IMember)Formats the definition of the specified member according to syntax rules of the language.
FormatLiteral(this IProgrammingLanguage, object)Formats the given literal value according to syntax rules of the language.
FormatName(this IProgrammingLanguage, IMember, NameQualifier)Formats the name of the specified member according to syntax rules of the language.
FormatSignature(this IProgrammingLanguage, IMember, NameQualifier)Formats the signature of the specified member according to syntax rules of the language.