public void GeneratesCorrectCode() { var myInterface = new CSharpIdentifier(ns: "Namespace1", name: "MyInterface"); var baseInterface = new CSharpIdentifier(ns: "Namespace2", name: "BaseInterface"); var endpointInterface = new CSharpIdentifier("TypedRest.Endpoints.Generic", "ICollectionEndpoint") { TypeArguments = { new CSharpIdentifier(ns: "Models", name: "MyModel") } }; var dummyAttribute = new CSharpAttribute(new CSharpIdentifier("Attributes", "DummyAttribute")) { Arguments = { "myValue" },
public void GeneratesCorrectCode() { var myClass = new CSharpIdentifier(ns: "Namespace1", name: "MyClass"); var myModel = new CSharpIdentifier(ns: "Models", name: "MyModel"); var myInterface = new CSharpIdentifier(ns: "Namespace1", name: "MyInterface") { TypeArguments = { myModel } }; var otherClass = new CSharpIdentifier(ns: "Namespace1", name: "OtherClass") { TypeArguments = { myModel } }; var baseClass = new CSharpIdentifier(ns: "Namespace2", name: "BaseClass"); var endpointInterface = new CSharpIdentifier("TypedRest.Endpoints", "IEndpoint"); var dummyAttribute = new CSharpAttribute(new CSharpIdentifier("Attributes", "DummyAttribute")) { Arguments = { "myValue" },
/// <summary> /// Creates a new C# enum. /// </summary> /// <param name="identifier">The fully qualified name of the enum.</param> public CSharpEnum(CSharpIdentifier identifier) : base(identifier) { }
public void GeneratesCorrectCode() { var myEnum = new CSharpIdentifier(ns: "Namespace1", name: "MyEnum"); var dummyAttribute = new CSharpAttribute(new CSharpIdentifier("Attributes", "DummyAttribute")) { Arguments = { "myValue" },
/// <summary> /// Creates a new constructor. /// </summary> /// <param name="type">The fully qualified name of the class that the constructor instantiates.</param> public CSharpConstructor(CSharpIdentifier type) { Type = type ?? throw new ArgumentNullException(nameof(type)); }
/// <summary> /// Creates a new C# type. /// </summary> /// <param name="identifier">The fully qualified name of the type.</param> protected CSharpType(CSharpIdentifier identifier) { Identifier = identifier ?? throw new ArgumentNullException(nameof(identifier)); }
/// <summary> /// Returns a copy of the identifier with an <c>I</c> prepended to the <see cref="Name"/>. /// </summary> public CSharpIdentifier ToInterface() { var result = new CSharpIdentifier(Namespace, "I" + Name); result.TypeArguments.AddRange(TypeArguments); return result; }
/// <summary> /// Creates a new C# class. /// </summary> /// <param name="identifier">The fully qualified name of the class.</param> public CSharpClass(CSharpIdentifier identifier) : base(identifier) { }
public static CSharpIdentifier DictionaryOf(CSharpIdentifier keyType, CSharpIdentifier valueType) => new CSharpIdentifier("System.Collections.Generic", "Dictionary") { TypeArguments = { keyType, valueType } };
public static CSharpIdentifier ListOf(CSharpIdentifier type) => new CSharpIdentifier("System.Collections.Generic", "List") { TypeArguments = { type } };
/// <summary> /// Creates a new attribute. /// </summary> /// <param name="identifier">The type of the attribute.</param> public CSharpAttribute(CSharpIdentifier identifier) { Identifier = identifier ?? throw new ArgumentNullException(nameof(identifier)); }
/// <summary> /// Creates a new C# interface. /// </summary> /// <param name="identifier">The fully qualified name of the interface.</param> public CSharpInterface(CSharpIdentifier identifier) : base(identifier) { }
/// <summary> /// Creates a new property. /// </summary> /// <param name="type">The type of the property.</param> /// <param name="name">The name of the property.</param> public CSharpProperty(CSharpIdentifier type, string name) { Type = type ?? throw new ArgumentNullException(nameof(type)); Name = name ?? throw new ArgumentNullException(nameof(name)); }