From e9333e519b2f14d46ad5c14dfabc4ae234b750c8 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Fri, 4 Aug 2023 17:13:47 +0200 Subject: [PATCH 01/16] added type model classes --- .../TypeGen.Core/TypeModel/Csharp/CsClass.cs | 17 ++++++++++++++ .../TypeGen.Core/TypeModel/Csharp/CsEnum.cs | 22 +++++++++++++++++++ .../TypeModel/Csharp/CsEnumValue.cs | 13 +++++++++++ .../TypeGen.Core/TypeModel/Csharp/CsField.cs | 9 ++++++++ .../TypeModel/Csharp/CsGenericParameter.cs | 11 ++++++++++ .../TypeModel/Csharp/CsInterface.cs | 16 ++++++++++++++ .../TypeModel/Csharp/CsProperty.cs | 9 ++++++++ .../TypeGen.Core/TypeModel/Csharp/CsType.cs | 14 ++++++++++++ .../TypeModel/TypeScript/TsClass.cs | 16 ++++++++++++++ .../TypeModel/TypeScript/TsEnum.cs | 12 ++++++++++ .../TypeModel/TypeScript/TsEnumValue.cs | 8 +++++++ .../TypeModel/TypeScript/TsImport.cs | 9 ++++++++ .../TypeModel/TypeScript/TsInterface.cs | 14 ++++++++++++ .../TypeModel/TypeScript/TsProperty.cs | 9 ++++++++ .../TypeModel/TypeScript/TsType.cs | 13 +++++++++++ .../TypeScript/TsUnderlyingValueType.cs | 7 ++++++ 16 files changed, 199 insertions(+) create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsClass.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnumValue.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGenericParameter.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsInterface.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsClass.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnum.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnumValue.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsImport.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsInterface.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsProperty.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsType.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsUnderlyingValueType.cs diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsClass.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsClass.cs new file mode 100644 index 00000000..928bf680 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsClass.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace TypeGen.Core.TypeModel.Csharp; + +internal class CsClass : CsType +{ + public CsClass(string name) : base(name) + { + } + + public string FullName { get; } + public IReadOnlyCollection GenericTypes { get; } + public IReadOnlyCollection Fields { get; } + public IReadOnlyCollection Properties { get; } + public IReadOnlyCollection Attributes { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs new file mode 100644 index 00000000..e8345b1a --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; + +namespace TypeGen.Core.TypeModel.Csharp; + +internal class CsEnum : CsType +{ + public CsEnum(string fullName, + string name, + IReadOnlyCollection attributes, + IReadOnlyCollection values) + : base(name) + { + FullName = fullName; + Values = values; + Attributes = attributes; + } + + public string FullName { get; } + public IReadOnlyCollection Attributes { get; } + public IReadOnlyCollection Values { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnumValue.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnumValue.cs new file mode 100644 index 00000000..ad318a36 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnumValue.cs @@ -0,0 +1,13 @@ +namespace TypeGen.Core.TypeModel.Csharp; + +internal class CsEnumValue +{ + public CsEnumValue(string name, object underlyingValue) + { + Name = name; + UnderlyingValue = underlyingValue; + } + + public string Name { get; } + public object UnderlyingValue { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs new file mode 100644 index 00000000..e742d3f3 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs @@ -0,0 +1,9 @@ +namespace TypeGen.Core.TypeModel.Csharp; + +internal class CsField +{ + public CsType Type { get; } + public bool IsTypeNullable { get; } + public string Name { get; } + public object DefaultValue { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGenericParameter.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGenericParameter.cs new file mode 100644 index 00000000..ceef7c09 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGenericParameter.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; + +namespace TypeGen.Core.TypeModel.Csharp; + +internal class CsGenericParameter : CsType +{ + public CsGenericParameter(string name) : base(name) + { + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsInterface.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsInterface.cs new file mode 100644 index 00000000..6f49ba32 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsInterface.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; + +namespace TypeGen.Core.TypeModel.Csharp; + +internal class CsInterface : CsType +{ + public CsInterface(string name) : base(name) + { + } + + public string FullName { get; } + public IReadOnlyCollection GenericTypes { get; } + public IReadOnlyCollection Properties { get; } + public IReadOnlyCollection Attributes { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs new file mode 100644 index 00000000..d4ed91d7 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs @@ -0,0 +1,9 @@ +namespace TypeGen.Core.TypeModel.Csharp; + +internal class CsProperty +{ + public CsType Type { get; } + public bool IsTypeNullable { get; } + public string Name { get; } + public object DefaultValue { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs new file mode 100644 index 00000000..d712d35c --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; + +namespace TypeGen.Core.TypeModel.Csharp; + +internal abstract class CsType +{ + protected CsType(string name) + { + Name = name; + } + + public string Name { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsClass.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsClass.cs new file mode 100644 index 00000000..ab690b52 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsClass.cs @@ -0,0 +1,16 @@ +using System.Collections.Generic; + +namespace TypeGen.Core.TypeModel.TypeScript; + +internal class TsClass : TsType +{ + public TsClass(string name, IReadOnlyCollection imports) + : base(name) + { + } + + public IReadOnlyCollection Imports { get; } + public string Base { get; } + public IReadOnlyCollection ImplementedInterfaces { get; set; } + public IReadOnlyCollection Properties { get; set; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnum.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnum.cs new file mode 100644 index 00000000..f3bb10e4 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnum.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace TypeGen.Core.TypeModel.TypeScript; + +internal class TsEnum : TsType +{ + public TsEnum(string name) : base(name) + { + } + + public IReadOnlyCollection Values { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnumValue.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnumValue.cs new file mode 100644 index 00000000..f1a829cb --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnumValue.cs @@ -0,0 +1,8 @@ +namespace TypeGen.Core.TypeModel.TypeScript; + +internal class TsEnumValue +{ + public string Name { get; } + public string UnderlyingValue { get; } + public TsUnderlyingValueType UnderlyingValueType { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsImport.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsImport.cs new file mode 100644 index 00000000..8a630cd5 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsImport.cs @@ -0,0 +1,9 @@ +namespace TypeGen.Core.TypeModel.TypeScript; + +internal class TsImport +{ + public string TypeName { get; } + public string OriginalTypeName { get; } + public string ImportPath { get; } + public bool IsDefaultExport { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsInterface.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsInterface.cs new file mode 100644 index 00000000..f763da20 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsInterface.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic; + +namespace TypeGen.Core.TypeModel.TypeScript; + +internal class TsInterface : TsType +{ + public TsInterface(string name) : base(name) + { + } + + public IReadOnlyCollection Imports { get; } + public string Base { get; } + public IReadOnlyCollection Properties { get; set; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsProperty.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsProperty.cs new file mode 100644 index 00000000..a08b7741 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsProperty.cs @@ -0,0 +1,9 @@ +namespace TypeGen.Core.TypeModel.TypeScript; + +internal class TsProperty +{ + public string Type { get; } + public string Name { get; } + public bool IsOptional { get; } + public string DefaultValue { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsType.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsType.cs new file mode 100644 index 00000000..5feae070 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsType.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; + +namespace TypeGen.Core.TypeModel.TypeScript; + +internal abstract class TsType +{ + protected TsType(string name) + { + Name = name; + } + + public string Name { get; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsUnderlyingValueType.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsUnderlyingValueType.cs new file mode 100644 index 00000000..d14053bf --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsUnderlyingValueType.cs @@ -0,0 +1,7 @@ +namespace TypeGen.Core.TypeModel.TypeScript; + +internal enum TsUnderlyingValueType +{ + Number, + String +} \ No newline at end of file From f9964838b2f1906b7034870ab341ca44d8ef30c7 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Fri, 4 Aug 2023 17:14:08 +0200 Subject: [PATCH 02/16] minor xmldoc rewording in GeneratorOptions.cs --- src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs b/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs index 17e70545..54c1c925 100644 --- a/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs +++ b/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs @@ -45,7 +45,7 @@ public class GeneratorOptions public TypeNameConverterCollection TypeNameConverters { get; set; } = DefaultTypeNameConverters; /// - /// A collection (chain) of converters used for converting C# class property names to TypeScript class property names + /// A collection (chain) of converters used for converting C# property names to TypeScript property names /// public MemberNameConverterCollection PropertyNameConverters { get; set; } = DefaultPropertyNameConverters; From d404c6fc5cf78c95dd2a2539d4d5479e20a2c309 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Fri, 4 Aug 2023 20:05:16 +0200 Subject: [PATCH 03/16] added logic for converting from Reflection to the C# model --- .../Extensions/AttributeExtensions.cs | 23 +++++ .../Extensions/EnumerableExtensions.cs | 3 + .../TypeGen.Core/Extensions/TypeExtensions.cs | 15 ++- .../ReflectionToCsModelConverter.cs | 91 +++++++++++++++++++ .../TypeGen.Core/TypeModel/Csharp/CsClass.cs | 17 ---- .../TypeGen.Core/TypeModel/Csharp/CsEnum.cs | 11 ++- .../TypeGen.Core/TypeModel/Csharp/CsField.cs | 8 +- .../TypeModel/Csharp/CsGenericParameter.cs | 2 +- .../TypeGen.Core/TypeModel/Csharp/CsGpType.cs | 39 ++++++++ .../TypeModel/Csharp/CsInterface.cs | 16 ---- .../TypeModel/Csharp/CsProperty.cs | 8 +- .../TypeGen.Core/TypeModel/Csharp/CsType.cs | 4 +- 12 files changed, 193 insertions(+), 44 deletions(-) create mode 100644 src/TypeGen/TypeGen.Core/Extensions/AttributeExtensions.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs delete mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsClass.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs delete mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsInterface.cs diff --git a/src/TypeGen/TypeGen.Core/Extensions/AttributeExtensions.cs b/src/TypeGen/TypeGen.Core/Extensions/AttributeExtensions.cs new file mode 100644 index 00000000..2fe17ac7 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/Extensions/AttributeExtensions.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using TypeGen.Core.TypeAnnotations; +using TypeGen.Core.Validation; + +namespace TypeGen.Core.Extensions; + +internal static class AttributeExtensions +{ + public static IEnumerable GetTypeGenAttributes(this IEnumerable @this) + { + Requires.NotNull(@this, nameof(@this)); + return @this.Where(x => x.IsTypeGenAttribute()); + } + + public static bool IsTypeGenAttribute(this Attribute @this) + { + Requires.NotNull(@this, nameof(@this)); + var tgAttributesNamespace = typeof(ExportAttribute).Namespace; + return @this.GetType().Namespace == tgAttributesNamespace; + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/Extensions/EnumerableExtensions.cs b/src/TypeGen/TypeGen.Core/Extensions/EnumerableExtensions.cs index 6d92316b..716c4c61 100644 --- a/src/TypeGen/TypeGen.Core/Extensions/EnumerableExtensions.cs +++ b/src/TypeGen/TypeGen.Core/Extensions/EnumerableExtensions.cs @@ -76,5 +76,8 @@ public static bool IsNullOrEmpty(this IEnumerable enumerable) /// /// public static bool None(this IEnumerable enumerable, Func predicate) => !enumerable.Any(predicate); + + public static bool Contains(this IEnumerable enumerable, Func predicate) + => enumerable.Where(predicate).Any(); } } diff --git a/src/TypeGen/TypeGen.Core/Extensions/TypeExtensions.cs b/src/TypeGen/TypeGen.Core/Extensions/TypeExtensions.cs index 0845fc76..e18be5b5 100644 --- a/src/TypeGen/TypeGen.Core/Extensions/TypeExtensions.cs +++ b/src/TypeGen/TypeGen.Core/Extensions/TypeExtensions.cs @@ -104,11 +104,22 @@ public static bool IsStatic(this MemberInfo memberInfo) public static bool IsNullable(this MemberInfo memberInfo) { Requires.NotNull(memberInfo, nameof(memberInfo)); - + var contextualMember = memberInfo.ToContextualAccessor(); return contextualMember.Nullability == Nullability.Nullable; } - + + /// + /// Checks if a property or field is nullable + /// + /// + /// + public static bool IsNullable(this Type type) + { + Requires.NotNull(type, nameof(type)); + return Nullable.GetUnderlyingType(type) != null; + } + /// /// Maps an enumerable to an enumerable of the elements' type names /// diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs b/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs new file mode 100644 index 00000000..d26a513e --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using TypeGen.Core.Extensions; +using TypeGen.Core.Metadata; +using TypeGen.Core.TypeModel.Csharp; +using TypeGen.Core.TypeModel.TypeScript; +using TypeGen.Core.Validation; + +namespace TypeGen.Core.TypeModel.Conversion; + +internal class ReflectionToCsModelConverter +{ + public static CsType ConvertType(Type type) + { + Requires.NotNull(type, nameof(type)); + + if (type.IsNullable()) + return ConvertTypePrivate(Nullable.GetUnderlyingType(type), true); + else + return ConvertTypePrivate(type, false); + } + + private static CsType ConvertTypePrivate(Type type, bool isNullable) + { + if (type.IsGenericParameter) + return ConvertGenericParameter(type); + + if (type.IsEnum) + return ConvertEnum(type, isNullable); + + if (type.IsClass) + return ConvertClass(type, isNullable); + + return null; + } + + private static CsGenericParameter ConvertGenericParameter(Type type) + { + return new CsGenericParameter(type.Name); + } + + private static CsEnum ConvertEnum(Type type, bool isNullable) + { + var values = type.GetFields(BindingFlags.Public | BindingFlags.Static) + .Select(fieldInfo => + { + var enumValue = fieldInfo.GetValue(null); + var underlyingValue = Convert.ChangeType(enumValue, Enum.GetUnderlyingType(type)); + return new CsEnumValue(fieldInfo.Name, underlyingValue); + }) + .ToList(); + + var tgAttributes = type.GetCustomAttributes().GetTypeGenAttributes().ToList(); + + return new CsEnum(type.FullName, type.Name, tgAttributes, values, isNullable); + } + + private static CsGpType ConvertClass(Type type, bool isNullable) + { + var reflectionGenericTypes = type.IsGenericTypeDefinition + ? type.GetTypeInfo().GenericTypeParameters + : type.GenericTypeArguments; + var genericTypes = reflectionGenericTypes.Select(ConvertType); + + var tgAttributes = type.GetCustomAttributes().GetTypeGenAttributes(); + + var properties = type.GetProperties() + .Select(propertyInfo => + { + var propertyType = ConvertType(propertyInfo.PropertyType); + var name = propertyInfo.Name; + var defaultValue = propertyInfo.GetValue(null); + return new CsProperty(propertyType, name, defaultValue); + }) + .ToList(); + + var fields = type.GetFields() + .Select(fieldInfo => + { + var fieldType = ConvertType(fieldInfo.FieldType); + var name = fieldInfo.Name; + var defaultValue = fieldInfo.GetValue(null); + return new CsField(fieldType, name, defaultValue); + }) + .ToList(); + + return null; + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsClass.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsClass.cs deleted file mode 100644 index 928bf680..00000000 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsClass.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TypeGen.Core.TypeModel.Csharp; - -internal class CsClass : CsType -{ - public CsClass(string name) : base(name) - { - } - - public string FullName { get; } - public IReadOnlyCollection GenericTypes { get; } - public IReadOnlyCollection Fields { get; } - public IReadOnlyCollection Properties { get; } - public IReadOnlyCollection Attributes { get; } -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs index e8345b1a..afb7f227 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs @@ -7,16 +7,17 @@ internal class CsEnum : CsType { public CsEnum(string fullName, string name, - IReadOnlyCollection attributes, - IReadOnlyCollection values) - : base(name) + IReadOnlyCollection tgAttributes, + IReadOnlyCollection values, + bool isNullable) + : base(name, isNullable) { FullName = fullName; Values = values; - Attributes = attributes; + TgAttributes = tgAttributes; } public string FullName { get; } - public IReadOnlyCollection Attributes { get; } + public IReadOnlyCollection TgAttributes { get; } public IReadOnlyCollection Values { get; } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs index e742d3f3..81bade92 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs @@ -2,8 +2,14 @@ namespace TypeGen.Core.TypeModel.Csharp; internal class CsField { + public CsField(CsType type, string name, object defaultValue) + { + Type = type; + Name = name; + DefaultValue = defaultValue; + } + public CsType Type { get; } - public bool IsTypeNullable { get; } public string Name { get; } public object DefaultValue { get; } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGenericParameter.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGenericParameter.cs index ceef7c09..6872a9d1 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGenericParameter.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGenericParameter.cs @@ -5,7 +5,7 @@ namespace TypeGen.Core.TypeModel.Csharp; internal class CsGenericParameter : CsType { - public CsGenericParameter(string name) : base(name) + public CsGenericParameter(string name) : base(name, false) { } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs new file mode 100644 index 00000000..42b34d52 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using TypeGen.Core.Extensions; + +namespace TypeGen.Core.TypeModel.Csharp; + +/// +/// General purpose C# type. Covers classes, interfaces, structs, records etc. +/// +internal class CsGpType : CsType +{ + public CsGpType(string name, bool isNullable) + : base(name, isNullable) + { + } + + public string FullName { get; } + public IReadOnlyCollection GenericTypes { get; } + public CsType Base { get; } + public IReadOnlyCollection ImplementedInterfaces { get; } + public IReadOnlyCollection Fields { get; } + public IReadOnlyCollection Properties { get; } + public IReadOnlyCollection TgAttributes { get; } + + public bool IsNonDictionaryEnumerable => + FullName != "System.String" + && !IsDictionary + && (ImplementsInterfaceByName("IEnumerable") || FullName.StartsWith("System.Collections.IEnumerable")); + + public bool IsDictionary => + ImplementsInterfaceByFullName("System.Collections.Generic.IDictionary`2") + || FullName.StartsWith("System.Collections.Generic.IDictionary`2") + || ImplementsInterfaceByFullName("System.Collections.IDictionary") + || FullName.StartsWith("System.Collections.IDictionary"); + + private bool ImplementsInterfaceByName(string name) => ImplementedInterfaces.Contains(x => x.Name == name); + private bool ImplementsInterfaceByFullName(string fullName) => ImplementedInterfaces.Contains(x => x.FullName == fullName); +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsInterface.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsInterface.cs deleted file mode 100644 index 6f49ba32..00000000 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsInterface.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace TypeGen.Core.TypeModel.Csharp; - -internal class CsInterface : CsType -{ - public CsInterface(string name) : base(name) - { - } - - public string FullName { get; } - public IReadOnlyCollection GenericTypes { get; } - public IReadOnlyCollection Properties { get; } - public IReadOnlyCollection Attributes { get; } -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs index d4ed91d7..26b88b54 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs @@ -2,8 +2,14 @@ namespace TypeGen.Core.TypeModel.Csharp; internal class CsProperty { + public CsProperty(CsType type, string name, object defaultValue) + { + Type = type; + Name = name; + DefaultValue = defaultValue; + } + public CsType Type { get; } - public bool IsTypeNullable { get; } public string Name { get; } public object DefaultValue { get; } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs index d712d35c..883f6940 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs @@ -5,10 +5,12 @@ namespace TypeGen.Core.TypeModel.Csharp; internal abstract class CsType { - protected CsType(string name) + protected CsType(string name, bool isNullable) { Name = name; + IsNullable = isNullable; } public string Name { get; } + public bool IsNullable { get; } } \ No newline at end of file From ff33d90e5c85d5e49ea2fe334cf7cb0df517f2cb Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Sun, 6 Aug 2023 00:33:48 +0200 Subject: [PATCH 04/16] added logic for converting between cs and ts models; CLI restructuring for testability --- .../Business/ConsoleArgsReaderTest.cs | 28 ++-- .../TypeGen.Cli/Business/ConsoleArgsReader.cs | 28 ++-- .../Business/IConsoleArgsReader.cs | 18 --- src/TypeGen/TypeGen.Cli/Program.cs | 23 ++-- src/TypeGen/TypeGen.Core/IsExternalInit.cs | 3 + .../ReflectionToCsModelConverter.cs | 126 ++++++++++++++---- .../TypeGen.Core/TypeModel/Csharp/CsGpType.cs | 91 ++++++++++--- .../TypeModel/Csharp/CsPrimitive.cs | 12 ++ 8 files changed, 226 insertions(+), 103 deletions(-) delete mode 100644 src/TypeGen/TypeGen.Cli/Business/IConsoleArgsReader.cs create mode 100644 src/TypeGen/TypeGen.Core/IsExternalInit.cs create mode 100644 src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsPrimitive.cs diff --git a/src/TypeGen/TypeGen.Cli.Test/Business/ConsoleArgsReaderTest.cs b/src/TypeGen/TypeGen.Cli.Test/Business/ConsoleArgsReaderTest.cs index a110984d..ea0597e7 100644 --- a/src/TypeGen/TypeGen.Cli.Test/Business/ConsoleArgsReaderTest.cs +++ b/src/TypeGen/TypeGen.Cli.Test/Business/ConsoleArgsReaderTest.cs @@ -7,13 +7,11 @@ namespace TypeGen.Cli.Test.Business { public class ConsoleArgsReaderTest { - private readonly IConsoleArgsReader _consoleArgsReader = new ConsoleArgsReader(); - [Theory] [MemberData(nameof(ContainsGetCwdCommand_TestData))] public void ContainsGetCwdCommand_Test(string[] args, bool expectedResult) { - bool actualResult = _consoleArgsReader.ContainsGetCwdCommand(args); + bool actualResult = ConsoleArgsReader.ContainsGetCwdCommand(args); Assert.Equal(expectedResult, actualResult); } @@ -31,7 +29,7 @@ public void ContainsGetCwdCommand_Test(string[] args, bool expectedResult) [MemberData(nameof(ContainsGenerateCommand_TestData))] public void ContainsGenerateCommand_Test(string[] args, bool expectedResult) { - bool actualResult = _consoleArgsReader.ContainsGenerateCommand(args); + bool actualResult = ConsoleArgsReader.ContainsGenerateCommand(args); Assert.Equal(expectedResult, actualResult); } @@ -49,7 +47,7 @@ public void ContainsGenerateCommand_Test(string[] args, bool expectedResult) [MemberData(nameof(ContainsAnyCommand_TestData))] public void ContainsAnyCommand_Test(string[] args, bool expectedResult) { - bool actualResult = _consoleArgsReader.ContainsAnyCommand(args); + bool actualResult = ConsoleArgsReader.ContainsAnyCommand(args); Assert.Equal(expectedResult, actualResult); } @@ -74,7 +72,7 @@ public void ContainsAnyCommand_Test(string[] args, bool expectedResult) [MemberData(nameof(ContainsHelpOption_TestData))] public void ContainsHelpOption_Test(string[] args, bool expectedResult) { - bool actualResult = _consoleArgsReader.ContainsHelpOption(args); + bool actualResult = ConsoleArgsReader.ContainsHelpOption(args); Assert.Equal(expectedResult, actualResult); } @@ -95,7 +93,7 @@ public void ContainsHelpOption_Test(string[] args, bool expectedResult) [MemberData(nameof(ContainsProjectFolderOption_TestData))] public void ContainsProjectFolderOption_Test(string[] args, bool expectedResult) { - bool actualResult = _consoleArgsReader.ContainsProjectFolderOption(args); + bool actualResult = ConsoleArgsReader.ContainsProjectFolderOption(args); Assert.Equal(expectedResult, actualResult); } @@ -116,7 +114,7 @@ public void ContainsProjectFolderOption_Test(string[] args, bool expectedResult) [MemberData(nameof(ContainsOutputFolderOption_TestData))] public void ContainsOutputFolderOption_Test(string[] args, bool expectedResult) { - bool actualResult = _consoleArgsReader.ContainsOutputOption(args); + bool actualResult = ConsoleArgsReader.ContainsOutputOption(args); Assert.Equal(expectedResult, actualResult); } @@ -137,7 +135,7 @@ public void ContainsOutputFolderOption_Test(string[] args, bool expectedResult) [MemberData(nameof(ContainsVerboseOption_TestData))] public void ContainsVerboseOption_Test(string[] args, bool expectedResult) { - bool actualResult = _consoleArgsReader.ContainsVerboseOption(args); + bool actualResult = ConsoleArgsReader.ContainsVerboseOption(args); Assert.Equal(expectedResult, actualResult); } @@ -158,7 +156,7 @@ public void ContainsVerboseOption_Test(string[] args, bool expectedResult) [MemberData(nameof(GetProjectFolders_TestData))] public void GetProjectFolders_Test(string[] args, IEnumerable expectedResult) { - IEnumerable actualResult = _consoleArgsReader.GetProjectFolders(args); + IEnumerable actualResult = ConsoleArgsReader.GetProjectFolders(args); Assert.Equal(expectedResult, actualResult); } @@ -176,14 +174,14 @@ public void GetProjectFolders_Test(string[] args, IEnumerable expectedRe public void GetProjectFolders_ParameterPresentAndNoPathsSpecified_ExceptionThrown() { var args = new[] { "--project-folder" }; - Assert.Throws(() => _consoleArgsReader.GetProjectFolders(args)); + Assert.Throws(() => ConsoleArgsReader.GetProjectFolders(args)); } [Theory] [MemberData(nameof(GetOutputFolder_TestData))] public void GetOutputFolder_Test(string[] args, string expectedResult) { - string actualResult = _consoleArgsReader.GetOutputFolder(args); + string actualResult = ConsoleArgsReader.GetOutputFolder(args); Assert.Equal(expectedResult, actualResult); } @@ -201,14 +199,14 @@ public void GetOutputFolder_Test(string[] args, string expectedResult) public void GetOutputFolder_ParameterPresentAndNoPathsSpecified_ExceptionThrown() { var args = new[] { "--output-folder" }; - Assert.Throws(() => _consoleArgsReader.GetOutputFolder(args)); + Assert.Throws(() => ConsoleArgsReader.GetOutputFolder(args)); } [Theory] [MemberData(nameof(GetConfigPaths_TestData))] public void GetConfigPaths_Test(string[] args, IEnumerable expectedResult) { - IEnumerable actualResult = _consoleArgsReader.GetConfigPaths(args); + IEnumerable actualResult = ConsoleArgsReader.GetConfigPaths(args); Assert.Equal(expectedResult, actualResult); } @@ -228,7 +226,7 @@ public void GetConfigPaths_Test(string[] args, IEnumerable expectedResul public void GetConfigPaths_ParameterPresentAndNoPathsSpecified_ExceptionThrown() { var args = new[] { "--config-path" }; - Assert.Throws(() => _consoleArgsReader.GetConfigPaths(args)); + Assert.Throws(() => ConsoleArgsReader.GetConfigPaths(args)); } } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Business/ConsoleArgsReader.cs b/src/TypeGen/TypeGen.Cli/Business/ConsoleArgsReader.cs index 5726ab75..0a040418 100644 --- a/src/TypeGen/TypeGen.Cli/Business/ConsoleArgsReader.cs +++ b/src/TypeGen/TypeGen.Cli/Business/ConsoleArgsReader.cs @@ -7,7 +7,7 @@ namespace TypeGen.Cli.Business { - internal class ConsoleArgsReader : IConsoleArgsReader + internal class ConsoleArgsReader { private const string GetCwdCommand = "GETCWD"; private const string GenerateCommand = "GENERATE"; @@ -17,22 +17,22 @@ internal class ConsoleArgsReader : IConsoleArgsReader /// private const string PathSeparator = "|"; - public bool ContainsGetCwdCommand(string[] args) => ContainsCommand(args, GetCwdCommand); - public bool ContainsGenerateCommand(string[] args) => ContainsCommand(args, GenerateCommand); - public bool ContainsAnyCommand(string[] args) => ContainsGenerateCommand(args) || ContainsGetCwdCommand(args); - private bool ContainsCommand(string[] args, string command) => args.Any(arg => string.Equals(arg, command, StringComparison.InvariantCultureIgnoreCase)); + public static bool ContainsGetCwdCommand(string[] args) => ContainsCommand(args, GetCwdCommand); + public static bool ContainsGenerateCommand(string[] args) => ContainsCommand(args, GenerateCommand); + public static bool ContainsAnyCommand(string[] args) => ContainsGenerateCommand(args) || ContainsGetCwdCommand(args); + private static bool ContainsCommand(string[] args, string command) => args.Any(arg => string.Equals(arg, command, StringComparison.InvariantCultureIgnoreCase)); - public bool ContainsHelpOption(string[] args) => ContainsOption(args, "-h", "--help"); - public bool ContainsProjectFolderOption(string[] args) => ContainsOption(args, "-p", "--project-folder"); - public bool ContainsOutputOption(string[] args) => ContainsOption(args, "-o", "--output-folder"); - public bool ContainsVerboseOption(string[] args) => ContainsOption(args, "-v", "--verbose"); - private bool ContainsOption(string[] args, string optionShortName, string optionFullName) => args.Any(arg => string.Equals(arg, optionShortName, StringComparison.InvariantCultureIgnoreCase) || string.Equals(arg, optionFullName, StringComparison.InvariantCultureIgnoreCase)); + public static bool ContainsHelpOption(string[] args) => ContainsOption(args, "-h", "--help"); + public static bool ContainsProjectFolderOption(string[] args) => ContainsOption(args, "-p", "--project-folder"); + public static bool ContainsOutputOption(string[] args) => ContainsOption(args, "-o", "--output-folder"); + public static bool ContainsVerboseOption(string[] args) => ContainsOption(args, "-v", "--verbose"); + private static bool ContainsOption(string[] args, string optionShortName, string optionFullName) => args.Any(arg => string.Equals(arg, optionShortName, StringComparison.InvariantCultureIgnoreCase) || string.Equals(arg, optionFullName, StringComparison.InvariantCultureIgnoreCase)); - public IEnumerable GetProjectFolders(string[] args) => GetPathsParam(args, "-p", "--project-folder"); - public string GetOutputFolder(string[] args) => GetPathsParam(args, "-o", "--output-folder").FirstOrDefault(); - public IEnumerable GetConfigPaths(string[] args) => GetPathsParam(args, "-c", "--config-path"); + public static IEnumerable GetProjectFolders(string[] args) => GetPathsParam(args, "-p", "--project-folder"); + public static string GetOutputFolder(string[] args) => GetPathsParam(args, "-o", "--output-folder").FirstOrDefault(); + public static IEnumerable GetConfigPaths(string[] args) => GetPathsParam(args, "-c", "--config-path"); - private IEnumerable GetPathsParam(string[] args, string paramShortName, string paramFullName) + private static IEnumerable GetPathsParam(string[] args, string paramShortName, string paramFullName) { int index = -1; diff --git a/src/TypeGen/TypeGen.Cli/Business/IConsoleArgsReader.cs b/src/TypeGen/TypeGen.Cli/Business/IConsoleArgsReader.cs deleted file mode 100644 index 2d3f38c3..00000000 --- a/src/TypeGen/TypeGen.Cli/Business/IConsoleArgsReader.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; - -namespace TypeGen.Cli.Business -{ - internal interface IConsoleArgsReader - { - bool ContainsGetCwdCommand(string[] args); - bool ContainsGenerateCommand(string[] args); - bool ContainsAnyCommand(string[] args); - bool ContainsHelpOption(string[] args); - bool ContainsProjectFolderOption(string[] args); - bool ContainsOutputOption(string[] args); - bool ContainsVerboseOption(string[] args); - IEnumerable GetProjectFolders(string[] args); - string GetOutputFolder(string[] args); - IEnumerable GetConfigPaths(string[] args); - } -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Program.cs b/src/TypeGen/TypeGen.Cli/Program.cs index 38c27ae3..58abcece 100644 --- a/src/TypeGen/TypeGen.Cli/Program.cs +++ b/src/TypeGen/TypeGen.Cli/Program.cs @@ -19,7 +19,6 @@ namespace TypeGen.Cli { internal class Program { - private static IConsoleArgsReader _consoleArgsReader; private static ILogger _logger; private static IFileSystem _fileSystem; private static IConfigProvider _configProvider; @@ -30,9 +29,7 @@ internal class Program private static void InitializeServices(string[] args) { - _consoleArgsReader = new ConsoleArgsReader(); - - bool verbose = _consoleArgsReader.ContainsVerboseOption(args); + bool verbose = ConsoleArgsReader.ContainsVerboseOption(args); _logger = new ConsoleLogger(verbose); _fileSystem = new FileSystem(); @@ -48,27 +45,27 @@ private static int Main(string[] args) { InitializeServices(args); - if (args == null || args.Length == 0 || _consoleArgsReader.ContainsHelpOption(args) || _consoleArgsReader.ContainsAnyCommand(args) == false) + if (args == null || args.Length == 0 || ConsoleArgsReader.ContainsHelpOption(args) || ConsoleArgsReader.ContainsAnyCommand(args) == false) { ShowHelp(); return (int)ExitCode.Success; } - if (_consoleArgsReader.ContainsGetCwdCommand(args)) + if (ConsoleArgsReader.ContainsGetCwdCommand(args)) { string cwd = _fileSystem.GetCurrentDirectory(); Console.WriteLine($"Current working directory is: {cwd}"); return (int)ExitCode.Success; } - string[] configPaths = _consoleArgsReader.GetConfigPaths(args).ToArray(); + string[] configPaths = ConsoleArgsReader.GetConfigPaths(args).ToArray(); - string[] projectFolders = _consoleArgsReader.ContainsProjectFolderOption(args) ? - _consoleArgsReader.GetProjectFolders(args).ToArray() : + string[] projectFolders = ConsoleArgsReader.ContainsProjectFolderOption(args) ? + ConsoleArgsReader.GetProjectFolders(args).ToArray() : new [] { "." }; - string? outputFolder = _consoleArgsReader.ContainsOutputOption(args) ? - _consoleArgsReader.GetOutputFolder(args) : null; + string? outputFolder = ConsoleArgsReader.ContainsOutputOption(args) ? + ConsoleArgsReader.GetOutputFolder(args) : null; for (var i = 0; i < projectFolders.Length; i++) { @@ -205,7 +202,9 @@ private static void ShowHelp() "generate Generate TypeScript files" + Environment.NewLine + "getcwd Get current working directory" + Environment.NewLine + Environment.NewLine + - "For more information please visit project's website: http://jburzynski.net/TypeGen"); + "For more information, visit:" + Environment.NewLine + + "Documentation: https://typegen.readthedocs.io" + Environment.NewLine + + "GitHub: https://github.com/jburzynski/TypeGen"); } } } diff --git a/src/TypeGen/TypeGen.Core/IsExternalInit.cs b/src/TypeGen/TypeGen.Core/IsExternalInit.cs new file mode 100644 index 00000000..499252ad --- /dev/null +++ b/src/TypeGen/TypeGen.Core/IsExternalInit.cs @@ -0,0 +1,3 @@ +namespace System.Runtime.CompilerServices; + +internal static class IsExternalInit {} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs b/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs index d26a513e..9b0dc189 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs @@ -1,11 +1,10 @@ +#nullable enable using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using TypeGen.Core.Extensions; -using TypeGen.Core.Metadata; using TypeGen.Core.TypeModel.Csharp; -using TypeGen.Core.TypeModel.TypeScript; using TypeGen.Core.Validation; namespace TypeGen.Core.TypeModel.Conversion; @@ -17,33 +16,96 @@ public static CsType ConvertType(Type type) Requires.NotNull(type, nameof(type)); if (type.IsNullable()) - return ConvertTypePrivate(Nullable.GetUnderlyingType(type), true); + return ConvertTypePrivate(Nullable.GetUnderlyingType(type)!, true); else return ConvertTypePrivate(type, false); } private static CsType ConvertTypePrivate(Type type, bool isNullable) + => type switch + { + { IsGenericParameter: true } => ConvertGenericParameter(type), + { IsPrimitive: true } => ConvertPrimitive(type, isNullable), + { IsEnum: true } => ConvertEnum(type, isNullable), + { IsClass: true } => ConvertClass(type, isNullable), + { IsInterface: true } => ConvertInterface(type, isNullable), + not null when type.IsStruct() => ConvertStruct(type, isNullable), + _ => throw new ArgumentException($"Type '{type!.FullName}' is not supported. Only classes, interfaces, structs, enums and generic parameters can be translated to TypeScript.") + }; + + private static CsGenericParameter ConvertGenericParameter(Type type) + { + return new CsGenericParameter(type.Name); + } + + private static CsPrimitive ConvertPrimitive(Type type, bool isNullable) + { + return new CsPrimitive(type.FullName, type.Name, isNullable); + } + + private static CsEnum ConvertEnum(Type type, bool isNullable) { - if (type.IsGenericParameter) - return ConvertGenericParameter(type); + var values = GetEnumValues(type); + var tgAttributes = GetTgAttributes(type); - if (type.IsEnum) - return ConvertEnum(type, isNullable); + return new CsEnum(type.FullName, type.Name, tgAttributes, values, isNullable); + } - if (type.IsClass) - return ConvertClass(type, isNullable); + private static CsGpType ConvertClass(Type type, bool isNullable) + { + var genericTypes = GetGenericTypes(type); + var @base = GetBase(type); + var implementedInterfaces = GetImplementedInterfaces(type); + var tgAttributes = GetTgAttributes(type); + var fields = GetFields(type); + var properties = GetProperties(type); - return null; + return CsGpType.Class(type.FullName!, + type.Name, + isNullable, + genericTypes, + @base, + implementedInterfaces, + fields, + properties, + tgAttributes); } - private static CsGenericParameter ConvertGenericParameter(Type type) + private static CsGpType ConvertInterface(Type type, bool isNullable) { - return new CsGenericParameter(type.Name); + var genericTypes = GetGenericTypes(type); + var @base = GetBase(type); + var tgAttributes = GetTgAttributes(type); + var properties = GetProperties(type); + + return CsGpType.Interface(type.FullName!, + type.Name, + isNullable, + genericTypes, + @base, + properties, + tgAttributes); } - private static CsEnum ConvertEnum(Type type, bool isNullable) + private static CsGpType ConvertStruct(Type type, bool isNullable) { - var values = type.GetFields(BindingFlags.Public | BindingFlags.Static) + var genericTypes = GetGenericTypes(type); + var tgAttributes = GetTgAttributes(type); + var fields = GetFields(type); + var properties = GetProperties(type); + + return CsGpType.Struct(type.FullName!, + type.Name, + isNullable, + genericTypes, + fields, + properties, + tgAttributes); + } + + private static IReadOnlyCollection GetEnumValues(Type type) + { + return type.GetFields(BindingFlags.Public | BindingFlags.Static) .Select(fieldInfo => { var enumValue = fieldInfo.GetValue(null); @@ -51,22 +113,30 @@ private static CsEnum ConvertEnum(Type type, bool isNullable) return new CsEnumValue(fieldInfo.Name, underlyingValue); }) .ToList(); - - var tgAttributes = type.GetCustomAttributes().GetTypeGenAttributes().ToList(); - - return new CsEnum(type.FullName, type.Name, tgAttributes, values, isNullable); } - - private static CsGpType ConvertClass(Type type, bool isNullable) + + private static IReadOnlyCollection GetGenericTypes(Type type) { var reflectionGenericTypes = type.IsGenericTypeDefinition ? type.GetTypeInfo().GenericTypeParameters : type.GenericTypeArguments; - var genericTypes = reflectionGenericTypes.Select(ConvertType); - - var tgAttributes = type.GetCustomAttributes().GetTypeGenAttributes(); + return reflectionGenericTypes.Select(ConvertType).ToList(); + } - var properties = type.GetProperties() + private static CsGpType? GetBase(Type type) + => type.BaseType != null ? (CsGpType)ConvertType(type.BaseType) : null; + + private static IReadOnlyCollection GetImplementedInterfaces(Type type) + => type.GetInterfaces() + .Select(ConvertType) + .Cast() + .ToList(); + + private static IReadOnlyCollection GetTgAttributes(Type type) + => type.GetCustomAttributes().GetTypeGenAttributes().ToList(); + + private static IReadOnlyCollection GetProperties(Type type) + => type.GetProperties() .Select(propertyInfo => { var propertyType = ConvertType(propertyInfo.PropertyType); @@ -75,8 +145,10 @@ private static CsGpType ConvertClass(Type type, bool isNullable) return new CsProperty(propertyType, name, defaultValue); }) .ToList(); - - var fields = type.GetFields() + + private static IReadOnlyCollection GetFields(Type type) + { + return type.GetFields() .Select(fieldInfo => { var fieldType = ConvertType(fieldInfo.FieldType); @@ -85,7 +157,5 @@ private static CsGpType ConvertClass(Type type, bool isNullable) return new CsField(fieldType, name, defaultValue); }) .ToList(); - - return null; } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs index 42b34d52..57903125 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs @@ -1,4 +1,6 @@ +#nullable enable using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using TypeGen.Core.Extensions; @@ -10,30 +12,87 @@ namespace TypeGen.Core.TypeModel.Csharp; /// internal class CsGpType : CsType { - public CsGpType(string name, bool isNullable) + private CsGpType(string name, bool isNullable) : base(name, isNullable) { } + + public static CsGpType Class(string fullName, + string name, + bool isNullable, + IReadOnlyCollection genericTypes, + CsGpType? @base, + IReadOnlyCollection implementedInterfaces, + IReadOnlyCollection fields, + IReadOnlyCollection properties, + IReadOnlyCollection tgAttributes) + { + return new CsGpType(name, isNullable) + { + FullName = fullName, + GenericTypes = genericTypes, + Base = @base, + ImplementedInterfaces = implementedInterfaces, + Fields = fields, + Properties = properties, + TgAttributes = tgAttributes + }; + } + + public static CsGpType Interface(string fullName, + string name, + bool isNullable, + IReadOnlyCollection genericTypes, + CsGpType? @base, + IReadOnlyCollection properties, + IReadOnlyCollection tgAttributes) + { + return new CsGpType(name, isNullable) + { + FullName = fullName, + GenericTypes = genericTypes, + Base = @base, + Properties = properties, + TgAttributes = tgAttributes + }; + } + + public static CsGpType Struct(string fullName, + string name, + bool isNullable, + IReadOnlyCollection genericTypes, + IReadOnlyCollection fields, + IReadOnlyCollection properties, + IReadOnlyCollection tgAttributes) + { + return new CsGpType(name, isNullable) + { + FullName = fullName, + GenericTypes = genericTypes, + Fields = fields, + Properties = properties, + TgAttributes = tgAttributes + }; + } - public string FullName { get; } - public IReadOnlyCollection GenericTypes { get; } - public CsType Base { get; } - public IReadOnlyCollection ImplementedInterfaces { get; } - public IReadOnlyCollection Fields { get; } - public IReadOnlyCollection Properties { get; } - public IReadOnlyCollection TgAttributes { get; } + public string FullName { get; init; } + public IReadOnlyCollection GenericTypes { get; init; } + public CsGpType? Base { get; init; } + public IReadOnlyCollection ImplementedInterfaces { get; init; } + public IReadOnlyCollection Fields { get; init; } + public IReadOnlyCollection Properties { get; init; } + public IReadOnlyCollection TgAttributes { get; init; } public bool IsNonDictionaryEnumerable => - FullName != "System.String" + FullName != typeof(string).FullName && !IsDictionary - && (ImplementsInterfaceByName("IEnumerable") || FullName.StartsWith("System.Collections.IEnumerable")); + && (ImplementsInterface(typeof(IEnumerable).FullName!) || FullName.StartsWith(typeof(IEnumerable).FullName!)); public bool IsDictionary => - ImplementsInterfaceByFullName("System.Collections.Generic.IDictionary`2") - || FullName.StartsWith("System.Collections.Generic.IDictionary`2") - || ImplementsInterfaceByFullName("System.Collections.IDictionary") - || FullName.StartsWith("System.Collections.IDictionary"); + ImplementsInterface(typeof(IDictionary<,>).FullName!) + || FullName.StartsWith(typeof(IDictionary<,>).FullName!) + || ImplementsInterface(typeof(IDictionary).FullName!) + || FullName.StartsWith(typeof(IDictionary).FullName!); - private bool ImplementsInterfaceByName(string name) => ImplementedInterfaces.Contains(x => x.Name == name); - private bool ImplementsInterfaceByFullName(string fullName) => ImplementedInterfaces.Contains(x => x.FullName == fullName); + private bool ImplementsInterface(string fullName) => ImplementedInterfaces.Contains(x => x.FullName == fullName); } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsPrimitive.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsPrimitive.cs new file mode 100644 index 00000000..37751fc5 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsPrimitive.cs @@ -0,0 +1,12 @@ +namespace TypeGen.Core.TypeModel.Csharp; + +internal class CsPrimitive : CsType +{ + public CsPrimitive(string fullName, string name, bool isNullable) + : base(name, isNullable) + { + FullName = fullName; + } + + public string FullName { get; } +} \ No newline at end of file From dbd41722587a8678f5a10e71f9a235b011654b35 Mon Sep 17 00:00:00 2001 From: "Spencer G. Jones" Date: Fri, 18 Aug 2023 09:15:45 -0600 Subject: [PATCH 05/16] Allow specifying custom header and body as an attribute or spec --- .../SpecGeneration/ClassSpecBuilderTest.cs | 28 ++++++++++++++++++- .../Generic/InterfaceSpecBuilderTest.cs | 28 ++++++++++++++++++- .../TypeGen.Core/Generator/Generator.cs | 16 ++++++++--- .../Builders/ClassSpecBuilderBase.cs | 16 ++++++++++- .../Builders/InterfaceSpecBuilderBase.cs | 16 ++++++++++- .../Builders/Traits/CustomBodyTrait.cs | 21 ++++++++++++++ .../Builders/Traits/CustomHeaderTrait.cs | 21 ++++++++++++++ .../Builders/Traits/ICustomBodyTrait.cs | 10 +++++++ .../Builders/Traits/ICustomHeaderTrait.cs | 10 +++++++ .../TypeGen.Core/SpecGeneration/TypeSpec.cs | 8 ++++-- .../TypeAnnotations/ExportAttribute.cs | 22 ++++++++++++++- 11 files changed, 184 insertions(+), 12 deletions(-) create mode 100644 src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/CustomBodyTrait.cs create mode 100644 src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/CustomHeaderTrait.cs create mode 100644 src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/ICustomBodyTrait.cs create mode 100644 src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/ICustomHeaderTrait.cs diff --git a/src/TypeGen/TypeGen.Core.Test/SpecGeneration/ClassSpecBuilderTest.cs b/src/TypeGen/TypeGen.Core.Test/SpecGeneration/ClassSpecBuilderTest.cs index 9b4ce06d..367d9ba1 100644 --- a/src/TypeGen/TypeGen.Core.Test/SpecGeneration/ClassSpecBuilderTest.cs +++ b/src/TypeGen/TypeGen.Core.Test/SpecGeneration/ClassSpecBuilderTest.cs @@ -57,6 +57,32 @@ public void CustomBase_Invoked_SpecUpdated() Assert.Equal(isDefaultExport, ((TsCustomBaseAttribute)attribute).IsDefaultExport); } + [Fact] + public void CustomHeader_Invoked_SpecUpdated() + { + const string header = "header"; + var spec = new TypeSpec(new ExportTsInterfaceAttribute()); + var builder = new ClassSpecBuilder(spec); + + builder.CustomHeader(header); + + var attribute = spec.ExportAttribute; + Assert.Equal(header, attribute.CustomHeader); + } + + [Fact] + public void CustomBody_Invoked_SpecUpdated() + { + const string body = "body"; + var spec = new TypeSpec(new ExportTsInterfaceAttribute()); + var builder = new ClassSpecBuilder(spec); + + builder.CustomBody(body); + + var attribute = spec.ExportAttribute; + Assert.Equal(body, attribute.CustomBody); + } + [Theory] [InlineData(true)] [InlineData(false)] @@ -256,4 +282,4 @@ public void Undefined_Invoked_SpecUpdated() Assert.IsType(attribute); } } -} \ No newline at end of file +} diff --git a/src/TypeGen/TypeGen.Core.Test/SpecGeneration/Generic/InterfaceSpecBuilderTest.cs b/src/TypeGen/TypeGen.Core.Test/SpecGeneration/Generic/InterfaceSpecBuilderTest.cs index 9f53e440..b7bd798a 100644 --- a/src/TypeGen/TypeGen.Core.Test/SpecGeneration/Generic/InterfaceSpecBuilderTest.cs +++ b/src/TypeGen/TypeGen.Core.Test/SpecGeneration/Generic/InterfaceSpecBuilderTest.cs @@ -85,6 +85,32 @@ public void CustomBase_Invoked_SpecUpdated() Assert.Equal(isDefaultExport, ((TsCustomBaseAttribute)attribute).IsDefaultExport); } + [Fact] + public void CustomHeader_Invoked_SpecUpdated() + { + const string header = "header"; + var spec = new TypeSpec(new ExportTsInterfaceAttribute()); + var builder = new TypeGen.Core.SpecGeneration.Builders.Generic.InterfaceSpecBuilder(spec); + + builder.CustomHeader(header); + + var attribute = spec.ExportAttribute; + Assert.Equal(header, attribute.CustomHeader); + } + + [Fact] + public void CustomBody_Invoked_SpecUpdated() + { + const string body = "body"; + var spec = new TypeSpec(new ExportTsInterfaceAttribute()); + var builder = new TypeGen.Core.SpecGeneration.Builders.Generic.InterfaceSpecBuilder(spec); + + builder.CustomBody(body); + + var attribute = spec.ExportAttribute; + Assert.Equal(body, attribute.CustomBody); + } + [Theory] [InlineData(true)] [InlineData(false)] @@ -271,4 +297,4 @@ public void Undefined_Invoked_SpecUpdated() Assert.IsType(attribute); } } -} \ No newline at end of file +} diff --git a/src/TypeGen/TypeGen.Core/Generator/Generator.cs b/src/TypeGen/TypeGen.Core/Generator/Generator.cs index f4a37242..7c3e6fc3 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Generator.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Generator.cs @@ -409,8 +409,12 @@ private IEnumerable GenerateClass(Type type, ExportTsClassAttribute clas string tsTypeNameFirstPart = tsTypeName.RemoveTypeGenericComponent(); string filePath = GetFilePath(type, outputDir); string filePathRelative = GetRelativeFilePath(type, outputDir); - string customHead = _tsContentGenerator.GetCustomHead(filePath); - string customBody = _tsContentGenerator.GetCustomBody(filePath, Options.TabLength); + string customInFileHead = _tsContentGenerator.GetCustomHead(filePath); + string customAttributeHead = classAttribute.CustomHeader; + string customHead = string.Join(Environment.NewLine, new[] { customInFileHead, customAttributeHead }.Where(i => !string.IsNullOrWhiteSpace(i))); + string customInFileBody = _tsContentGenerator.GetCustomBody(filePath, Options.TabLength); + string customAttributeBody = classAttribute.CustomBody; + string customBody = string.Join(Environment.NewLine, new[] { customInFileBody, customAttributeBody }.Where(i => !string.IsNullOrWhiteSpace(i))); var tsDoc = GetTsDocForType(type); var content = _typeService.UseDefaultExport(type) ? @@ -458,8 +462,12 @@ private IEnumerable GenerateInterface(Type type, ExportTsInterfaceAttrib string tsTypeNameFirstPart = tsTypeName.RemoveTypeGenericComponent(); string filePath = GetFilePath(type, outputDir); string filePathRelative = GetRelativeFilePath(type, outputDir); - string customHead = _tsContentGenerator.GetCustomHead(filePath); - string customBody = _tsContentGenerator.GetCustomBody(filePath, Options.TabLength); + string customInFileHead = _tsContentGenerator.GetCustomHead(filePath); + string customAttributeHead = interfaceAttribute.CustomHeader; + string customHead = string.Join(Environment.NewLine, new[] { customInFileHead, customAttributeHead }.Where(i => !string.IsNullOrWhiteSpace(i))); + string customInFileBody = _tsContentGenerator.GetCustomBody(filePath, Options.TabLength); + string customAttributeBody = interfaceAttribute.CustomBody; + string customBody = string.Join(Environment.NewLine, new[] { customInFileBody, customAttributeBody }.Where(i => !string.IsNullOrWhiteSpace(i))); var tsDoc = GetTsDocForType(type); var content = _typeService.UseDefaultExport(type) ? diff --git a/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/ClassSpecBuilderBase.cs b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/ClassSpecBuilderBase.cs index a39408a3..15d9866d 100644 --- a/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/ClassSpecBuilderBase.cs +++ b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/ClassSpecBuilderBase.cs @@ -6,6 +6,8 @@ namespace TypeGen.Core.SpecGeneration.Builders { public abstract class ClassSpecBuilderBase : SpecBuilderBase, ICustomBaseTrait, + ICustomHeaderTrait, + ICustomBodyTrait, IDefaultExportTrait, IDefaultTypeOutputTrait, IDefaultValueTrait, @@ -26,6 +28,8 @@ public abstract class ClassSpecBuilderBase : SpecBuilderBase, where TSelf : SpecBuilderBase { private readonly CustomBaseTrait _customBaseTrait; + private readonly CustomBodyTrait _customBodyTrait; + private readonly CustomHeaderTrait _customHeaderTrait; private readonly DefaultExportTrait _defaultExportTrait; private readonly DefaultTypeOutputTrait _defaultTypeOutputTrait; private readonly DefaultValueTrait _defaultValueTrait; @@ -48,6 +52,8 @@ internal ClassSpecBuilderBase(TypeSpec typeSpec) : base(typeSpec) { MemberTrait = new MemberTrait(this as TSelf, typeSpec); _customBaseTrait = new CustomBaseTrait(this as TSelf, typeSpec); + _customBodyTrait = new CustomBodyTrait(this as TSelf, typeSpec); + _customHeaderTrait = new CustomHeaderTrait(this as TSelf, typeSpec); _defaultExportTrait = new DefaultExportTrait(this as TSelf, typeSpec); _defaultTypeOutputTrait = new DefaultTypeOutputTrait(this as TSelf, typeSpec, MemberTrait); _defaultValueTrait = new DefaultValueTrait(this as TSelf, typeSpec, MemberTrait); @@ -75,7 +81,15 @@ public TSelf CustomBase(string @base = null, string importPath = null, string or public TSelf CustomBase(string @base = null, string importPath = null, string originalTypeName = null, bool isDefaultExport = false, params ImplementedInterface[] implementedInterfaces) => _customBaseTrait.CustomBase(@base, importPath, originalTypeName, isDefaultExport, implementedInterfaces); - + + /// + public TSelf CustomBody(string body) + => _customBodyTrait.CustomBody(body); + + /// + public TSelf CustomHeader(string header) + => _customHeaderTrait.CustomHeader(header); + /// public TSelf DefaultExport(bool enabled = true) => _defaultExportTrait.DefaultExport(enabled); diff --git a/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/InterfaceSpecBuilderBase.cs b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/InterfaceSpecBuilderBase.cs index a7558fa4..54efcd60 100644 --- a/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/InterfaceSpecBuilderBase.cs +++ b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/InterfaceSpecBuilderBase.cs @@ -9,6 +9,8 @@ namespace TypeGen.Core.SpecGeneration.Builders /// public abstract class InterfaceSpecBuilderBase : SpecBuilderBase, ICustomBaseTrait, + ICustomHeaderTrait, + ICustomBodyTrait, IDefaultExportTrait, IDefaultTypeOutputTrait, IDefaultValueTrait, @@ -28,6 +30,8 @@ public abstract class InterfaceSpecBuilderBase : SpecBuilderBase, where TSelf : SpecBuilderBase { private readonly CustomBaseTrait _customBaseTrait; + private readonly CustomBodyTrait _customBodyTrait; + private readonly CustomHeaderTrait _customHeaderTrait; private readonly DefaultExportTrait _defaultExportTrait; private readonly DefaultTypeOutputTrait _defaultTypeOutputTrait; private readonly DefaultValueTrait _defaultValueTrait; @@ -49,6 +53,8 @@ internal InterfaceSpecBuilderBase(TypeSpec typeSpec) : base(typeSpec) { MemberTrait = new MemberTrait(this as TSelf, typeSpec); _customBaseTrait = new CustomBaseTrait(this as TSelf, typeSpec); + _customBodyTrait = new CustomBodyTrait(this as TSelf, typeSpec); + _customHeaderTrait = new CustomHeaderTrait(this as TSelf, typeSpec); _defaultExportTrait = new DefaultExportTrait(this as TSelf, typeSpec); _defaultTypeOutputTrait = new DefaultTypeOutputTrait(this as TSelf, typeSpec, MemberTrait); _defaultValueTrait = new DefaultValueTrait(this as TSelf, typeSpec, MemberTrait); @@ -75,6 +81,14 @@ public TSelf CustomBase(string @base = null, string importPath = null, string or public TSelf CustomBase(string @base = null, string importPath = null, string originalTypeName = null, bool isDefaultExport = false, params ImplementedInterface[] implementedInterfaces) => _customBaseTrait.CustomBase(@base, importPath, originalTypeName, isDefaultExport, implementedInterfaces); + + /// + public TSelf CustomBody(string body) + => _customBodyTrait.CustomBody(body); + + /// + public TSelf CustomHeader(string header) + => _customHeaderTrait.CustomHeader(header); /// public TSelf DefaultExport(bool enabled = true) => _defaultExportTrait.DefaultExport(enabled); @@ -131,4 +145,4 @@ public TSelf Type(string typeName, string importPath = null, string originalType /// public TSelf Undefined() => _undefinedTrait.Undefined(); } -} \ No newline at end of file +} diff --git a/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/CustomBodyTrait.cs b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/CustomBodyTrait.cs new file mode 100644 index 00000000..90624a88 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/CustomBodyTrait.cs @@ -0,0 +1,21 @@ +using TypeGen.Core.TypeAnnotations; + +namespace TypeGen.Core.SpecGeneration.Builders.Traits; + +internal class CustomBodyTrait : ICustomBodyTrait +{ + private readonly TSpecBuilder _this; + private readonly TypeSpec _typeSpec; + + public CustomBodyTrait(TSpecBuilder @this, TypeSpec typeSpec) + { + _this = @this; + _typeSpec = typeSpec; + } + + public TSpecBuilder CustomBody(string body) + { + _typeSpec.SetCustomBody(body); + return _this; + } +} diff --git a/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/CustomHeaderTrait.cs b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/CustomHeaderTrait.cs new file mode 100644 index 00000000..5ece8940 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/CustomHeaderTrait.cs @@ -0,0 +1,21 @@ +using TypeGen.Core.TypeAnnotations; + +namespace TypeGen.Core.SpecGeneration.Builders.Traits; + +internal class CustomHeaderTrait : ICustomHeaderTrait +{ + private readonly TSpecBuilder _this; + private readonly TypeSpec _typeSpec; + + public CustomHeaderTrait(TSpecBuilder @this, TypeSpec typeSpec) + { + _this = @this; + _typeSpec = typeSpec; + } + + public TSpecBuilder CustomHeader(string header) + { + _typeSpec.SetCustomHeader(header); + return _this; + } +} diff --git a/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/ICustomBodyTrait.cs b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/ICustomBodyTrait.cs new file mode 100644 index 00000000..58dd12ce --- /dev/null +++ b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/ICustomBodyTrait.cs @@ -0,0 +1,10 @@ +namespace TypeGen.Core.SpecGeneration.Builders.Traits; + +internal interface ICustomBodyTrait +{ + /// + /// Indicates type has a custom body (equivalent of TsExportAttribute's CustomBody). + /// + /// The current instance of . + TSpecBuilder CustomBody(string body); +} diff --git a/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/ICustomHeaderTrait.cs b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/ICustomHeaderTrait.cs new file mode 100644 index 00000000..ab69a726 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/SpecGeneration/Builders/Traits/ICustomHeaderTrait.cs @@ -0,0 +1,10 @@ +namespace TypeGen.Core.SpecGeneration.Builders.Traits; + +internal interface ICustomHeaderTrait +{ + /// + /// Indicates type has a custom header (equivalent of TsExportAttribute's CustomHeader). + /// + /// The current instance of . + TSpecBuilder CustomHeader(string header); +} diff --git a/src/TypeGen/TypeGen.Core/SpecGeneration/TypeSpec.cs b/src/TypeGen/TypeGen.Core/SpecGeneration/TypeSpec.cs index f8f1f67e..89d131c6 100644 --- a/src/TypeGen/TypeGen.Core/SpecGeneration/TypeSpec.cs +++ b/src/TypeGen/TypeGen.Core/SpecGeneration/TypeSpec.cs @@ -21,7 +21,7 @@ public TypeSpec(ExportAttribute exportAttribute) _memberAttributes = new Dictionary>(); _additionalAttributes = new List(); } - + public void AddMember(string memberName) => _memberAttributes[memberName] = new List(); public void AddCustomBaseAttribute(string @base = null, string importPath = null, string originalTypeName = null, bool isDefaultExport = false, @@ -32,6 +32,8 @@ public void AddCustomBaseAttribute(string @base = null, string importPath = null public void AddDefaultValueAttribute(string memberName, string defaultValue) => AddMemberAttribute(memberName, new TsDefaultValueAttribute(defaultValue)); public void AddIgnoreAttribute(string memberName) => AddMemberAttribute(memberName, new TsIgnoreAttribute()); public void AddIgnoreBaseAttribute() => AddAdditionalAttribute(new TsIgnoreBaseAttribute()); + public void SetCustomHeader(string header) { ExportAttribute.CustomHeader = header; } + public void SetCustomBody(string body) { ExportAttribute.CustomBody = body; } public void AddMemberNameAttribute(string memberName, string name) => AddMemberAttribute(memberName, new TsMemberNameAttribute(name)); public void AddNotNullAttribute(string memberName) => AddMemberAttribute(memberName, new TsNotNullAttribute()); public void AddNotReadonlyAttribute(string memberName) => AddMemberAttribute(memberName, new TsNotReadonlyAttribute()); @@ -48,8 +50,8 @@ public void AddTypeAttribute(string memberName, string typeName, string importPa public void AddTypeUnionsAttribute(string memberName, IEnumerable typeUnions) => AddMemberAttribute(memberName, new TsTypeUnionsAttribute(typeUnions)); public void AddTypeUnionsAttribute(string memberName, params string[] typeUnions) => AddMemberAttribute(memberName, new TsTypeUnionsAttribute(typeUnions)); public void AddUndefinedAttribute(string memberName) => AddMemberAttribute(memberName, new TsUndefinedAttribute()); - + private void AddMemberAttribute(string memberName, Attribute attribute) => MemberAttributes[memberName].Add(attribute); private void AddAdditionalAttribute(Attribute attribute) => _additionalAttributes.Add(attribute); } -} \ No newline at end of file +} diff --git a/src/TypeGen/TypeGen.Core/TypeAnnotations/ExportAttribute.cs b/src/TypeGen/TypeGen.Core/TypeAnnotations/ExportAttribute.cs index 509dc0a4..be5b55d2 100644 --- a/src/TypeGen/TypeGen.Core/TypeAnnotations/ExportAttribute.cs +++ b/src/TypeGen/TypeGen.Core/TypeAnnotations/ExportAttribute.cs @@ -11,7 +11,9 @@ namespace TypeGen.Core.TypeAnnotations public abstract class ExportAttribute : Attribute { private string _outputDir; - + private string _customHeader; + private string _customBody; + /// /// TypeScript file output directory /// @@ -20,5 +22,23 @@ public string OutputDir get => _outputDir; set => _outputDir = FileSystemUtils.AsDirectory(value); } + + /// + /// TypeScript file custom header + /// + public string CustomHeader + { + get => _customHeader; + set => _customHeader = value; + } + + /// + /// TypeScript file custom body + /// + public string CustomBody + { + get => _customBody; + set => _customBody = value; + } } } From f6ad517faba48ca6a1e415673d49e2955d5a919d Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Tue, 22 Aug 2023 15:51:59 +0200 Subject: [PATCH 06/16] added the blacklist functionality to TypeGen.Core --- .../Extensions/StringExtensionsTest.cs | 2 +- .../Extensions/StringExtensions.cs | 15 ++- .../TypeGen.Core/Generator/Generator.cs | 80 ++++++++------- .../Generator/GeneratorOptions.cs | 48 ++++++++- .../Generator/Services/ITypeService.cs | 8 +- .../Generator/Services/TsContentGenerator.cs | 8 +- .../Services/TypeDependencyService.cs | 3 +- .../Generator/Services/TypeService.cs | 99 +++++++------------ .../SpecGeneration/GenerationSpec.cs | 2 + 9 files changed, 149 insertions(+), 116 deletions(-) diff --git a/src/TypeGen/TypeGen.Core.Test/Extensions/StringExtensionsTest.cs b/src/TypeGen/TypeGen.Core.Test/Extensions/StringExtensionsTest.cs index 415d9c78..dd57553b 100644 --- a/src/TypeGen/TypeGen.Core.Test/Extensions/StringExtensionsTest.cs +++ b/src/TypeGen/TypeGen.Core.Test/Extensions/StringExtensionsTest.cs @@ -53,7 +53,7 @@ public void RemoveTypeArity_Test(string input, string expectedResult) [InlineData("NonGenericType", "NonGenericType")] public void RemoveTypeGenericComponent_Test(string input, string expectedResult) { - string actualResult = input.RemoveTypeGenericComponent(); + string actualResult = input.RemoveTsTypeNameGenericComponent(); Assert.Equal(expectedResult, actualResult); } diff --git a/src/TypeGen/TypeGen.Core/Extensions/StringExtensions.cs b/src/TypeGen/TypeGen.Core/Extensions/StringExtensions.cs index d70117dd..23688010 100644 --- a/src/TypeGen/TypeGen.Core/Extensions/StringExtensions.cs +++ b/src/TypeGen/TypeGen.Core/Extensions/StringExtensions.cs @@ -62,16 +62,27 @@ public static string RemoveTypeArity(this string value) } /// - /// Removes generic component from the type, e.g. "MyType" becomes "MyType" + /// Removes generic component from the TypeScript type name, e.g. "MyType<T>" becomes "MyType" /// /// /// - public static string RemoveTypeGenericComponent(this string value) + public static string RemoveTsTypeNameGenericComponent(this string value) { Requires.NotNull(value, nameof(value)); return value.Split('<')[0]; } + /// + /// Removes generic arguments from the type name. + /// + /// + /// + public static string RemoveGenericArgumentsFromTypeName(this string value) + { + Requires.NotNull(value, nameof(value)); + return value.Split('[')[0]; + } + /// /// Gets the type from a TypeScript type union indicated by the given index. /// E.g. the following string: "Date | null | undefined" is a TS type union with 3 types and each of these types can be accessed with an index from 0 to 2. diff --git a/src/TypeGen/TypeGen.Core/Generator/Generator.cs b/src/TypeGen/TypeGen.Core/Generator/Generator.cs index 7c3e6fc3..729cbf50 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Generator.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Generator.cs @@ -118,7 +118,8 @@ public Task> GenerateAsync(IEnumerable gener public IEnumerable Generate(IEnumerable generationSpecs) { Requires.NotNullOrEmpty(generationSpecs, nameof(generationSpecs)); - + + generationSpecs = generationSpecs.ToList(); var files = new List(); _generationContext = new GenerationContext(_fileSystem); @@ -130,7 +131,7 @@ public IEnumerable Generate(IEnumerable generationSpecs) generationSpec.OnBeforeGeneration(new OnBeforeGenerationArgs(Options)); foreach (KeyValuePair kvp in generationSpec.TypeSpecs) - files.AddRange(GenerateTypePrivate(kvp.Key)); + files.AddRange(GenerateMarkedType(kvp.Key)); } files = files.Distinct().ToList(); @@ -152,7 +153,7 @@ public IEnumerable Generate(IEnumerable generationSpecs) return files; } - + /// /// Generates TypeScript files from an assembly /// @@ -303,8 +304,10 @@ private IEnumerable GenerateIndexFile(IEnumerable generatedFiles return new[] { filename }; } - private IEnumerable GenerateTypePrivate(Type type) + private IEnumerable GenerateMarkedType(Type type) { + if (Options.IsTypeBlacklisted(type)) return Enumerable.Empty(); + IEnumerable files = Enumerable.Empty(); _generationContext.BeginTypeGeneration(type); @@ -342,7 +345,7 @@ private IEnumerable GenerateType(Type type) return GenerateEnum(type, enumAttribute); } - return GenerateNotMarked(type, Options.BaseOutputDirectory); + return GenerateNotMarkedType(type, Options.BaseOutputDirectory); } /// @@ -351,8 +354,10 @@ private IEnumerable GenerateType(Type type) /// /// /// Generated TypeScript file paths (relative to the Options.BaseOutputDirectory) - private IEnumerable GenerateNotMarked(Type type, string outputDirectory) + private IEnumerable GenerateNotMarkedType(Type type, string outputDirectory) { + if (Options.IsTypeBlacklisted(type)) return Enumerable.Empty(); + var typeInfo = type.GetTypeInfo(); if (typeInfo.IsClass || typeInfo.IsStruct()) { @@ -406,7 +411,7 @@ private IEnumerable GenerateClass(Type type, ExportTsClassAttribute clas // generate the file content string tsTypeName = _typeService.GetTsTypeName(type, true); - string tsTypeNameFirstPart = tsTypeName.RemoveTypeGenericComponent(); + string tsTypeNameFirstPart = tsTypeName.RemoveTsTypeNameGenericComponent(); string filePath = GetFilePath(type, outputDir); string filePathRelative = GetRelativeFilePath(type, outputDir); string customInFileHead = _tsContentGenerator.GetCustomHead(filePath); @@ -459,7 +464,7 @@ private IEnumerable GenerateInterface(Type type, ExportTsInterfaceAttrib // generate the file content string tsTypeName = _typeService.GetTsTypeName(type, true); - string tsTypeNameFirstPart = tsTypeName.RemoveTypeGenericComponent(); + string tsTypeNameFirstPart = tsTypeName.RemoveTsTypeNameGenericComponent(); string filePath = GetFilePath(type, outputDir); string filePathRelative = GetRelativeFilePath(type, outputDir); string customInFileHead = _tsContentGenerator.GetCustomHead(filePath); @@ -549,7 +554,7 @@ private string GetClassPropertyText(Type type, MemberInfo memberInfo) var nameAttribute = _metadataReaderFactory.GetInstance().GetAttribute(memberInfo); string name = nameAttribute?.Name ?? Options.PropertyNameConverters.Convert(memberInfo.Name, memberInfo); - string typeName = _typeService.GetTsTypeName(memberInfo); + string typeName = _typeService.GetTsTypeName(memberInfo, MemberTypeIsBlacklistedCallback(memberInfo)); IEnumerable typeUnions = _typeService.GetTypeUnions(memberInfo); var tsDoc = GetTsDocForMember(type, memberInfo); @@ -577,6 +582,17 @@ private string GetClassPropertyText(Type type, MemberInfo memberInfo) return _templateService.FillClassPropertyTemplate(modifiers, name, typeName, typeUnions, isOptional, tsDoc); } + private static Action MemberTypeIsBlacklistedCallback(MemberInfo memberInfo) + { + return type => throw new CoreException($"Type '{type.FullName}'" + + $" used for member '{memberInfo.DeclaringType.FullName}.{memberInfo.Name}'" + + $" contains a blacklisted type. Possible solutions:" + + $"{Environment.NewLine}1. Remove the type from blacklist." + + $"{Environment.NewLine}2. Remove the member." + + $"{Environment.NewLine}3. Add TsTypeAttribute to the member." + + $"{Environment.NewLine}4. Create custom type mapping for the blacklisted type."); + } + private string GetTsDocForMember(Type type, MemberInfo memberInfo) { if (_generationContext.DoesNotContainXmlDocForAssembly(type.Assembly)) return ""; @@ -729,7 +745,7 @@ private string GetEnumMembersText(Type type, bool asUnionType) } /// - /// Generates type dependencies' files for a given type + /// Generates type dependencies for a given type /// /// /// @@ -737,40 +753,28 @@ private string GetEnumMembersText(Type type, bool asUnionType) private IEnumerable GenerateTypeDependencies(Type type, string outputDir) { var generatedFiles = new List(); - IEnumerable typeDependencies = _typeDependencyService.GetTypeDependencies(type); + var typeDependencies = _typeDependencyService.GetTypeDependencies(type); - foreach (TypeDependencyInfo typeDependencyInfo in typeDependencies) + foreach (var typeDependencyInfo in typeDependencies) { - Type typeDependency = typeDependencyInfo.Type; - - // dependency type TypeScript file generation + var typeDependency = typeDependencyInfo.Type; + if (typeDependency.HasExportAttribute(_metadataReaderFactory.GetInstance()) || _generationContext.IsTypeGenerated(typeDependency)) continue; + + var defaultOutputAttribute = typeDependencyInfo.MemberAttributes + ?.FirstOrDefault(a => a is TsDefaultTypeOutputAttribute) + as TsDefaultTypeOutputAttribute; - // dependency HAS an ExportTsX attribute (AND hasn't been generated yet) - if (typeDependency.HasExportAttribute(_metadataReaderFactory.GetInstance()) && !_generationContext.IsTypeGenerated(typeDependency)) + var defaultOutputDir = defaultOutputAttribute?.OutputDir ?? outputDir; + + _generationContext.AddGeneratedType(typeDependency); + + try { - _generationContext.AddGeneratedType(typeDependency); - generatedFiles.AddRange(GenerateTypePrivate(typeDependency)); + generatedFiles.AddRange(GenerateNotMarkedType(typeDependency, defaultOutputDir)); } - - // dependency DOESN'T HAVE an ExportTsX attribute (AND hasn't been generated for the currently generated type yet) - if (!typeDependency.HasExportAttribute(_metadataReaderFactory.GetInstance()) && !_generationContext.IsTypeGeneratedForType(typeDependency)) + catch (Exception ex) { - var defaultOutputAttribute = typeDependencyInfo.MemberAttributes - ?.FirstOrDefault(a => a is TsDefaultTypeOutputAttribute) - as TsDefaultTypeOutputAttribute; - - string defaultOutputDir = defaultOutputAttribute?.OutputDir ?? outputDir; - - _generationContext.AddGeneratedType(typeDependency); - - try - { - generatedFiles.AddRange(GenerateNotMarked(typeDependency, defaultOutputDir)); - } - catch (CoreException ex) - { - throw new CoreException($"Error generating dependencies types for {type.FullName}", ex); - } + throw new CoreException($"Error generating type dependencies for '{type.FullName}'", ex); } } diff --git a/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs b/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs index 54c1c925..35b3c063 100644 --- a/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs +++ b/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs @@ -1,7 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using TypeGen.Core.Converters; +using TypeGen.Core.Extensions; using TypeGen.Core.Generator.Services; using TypeGen.Core.Utils; +using TypeGen.Core.Validation; namespace TypeGen.Core.Generator { @@ -34,6 +37,21 @@ public class GeneratorOptions public static bool DefaultExportTypesAsInterfacesByDefault => false; public static bool DefaultUseImportType => false; + public static HashSet DefaultTypeBlacklist => new(new [] + { + "System.IAsyncDisposable", + typeof(ICloneable).FullName, + typeof(IComparable).FullName, + typeof(IComparable<>).FullName, + typeof(IConvertible).FullName, + typeof(IDisposable).FullName, + typeof(IEquatable<>).FullName, + typeof(IFormattable).FullName, + "System.IParsable`1", + "System.ISpanFormattable", + "System.ISpanParsable`1" + }); + /// /// A collection (chain) of converters used for converting C# file names to TypeScript file names /// @@ -162,5 +180,33 @@ public string BaseOutputDirectory /// public bool UseImportType { get; set; } = DefaultUseImportType; + /// + /// Specifies types which should not be generated. + /// + public HashSet TypeBlacklist { get; set; } = DefaultTypeBlacklist; + + /// + /// Checks if the type is on the type blacklist. + /// + /// The type. + /// true if the type is on the blacklist, false otherwise + public bool IsTypeBlacklisted(Type type) + { + Requires.NotNull(type, nameof(type)); + + if (type.IsGenericParameter) return false; + + var nameWithNamespace = $"{type.Namespace}.{type.Name}"; + + return TypeBlacklist.Contains(nameWithNamespace.RemoveGenericArgumentsFromTypeName()) + || TypeBlacklist.Contains(type.Name.RemoveGenericArgumentsFromTypeName()); + } + + /// + /// Checks if the type is not on the type blacklist. + /// + /// The type. + /// true if the type is not on the blacklist, false otherwise + public bool IsTypeNotBlacklisted(Type type) => !IsTypeBlacklisted(type); } } diff --git a/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs b/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs index a58e378a..6063d374 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs @@ -79,17 +79,19 @@ internal interface ITypeService /// /// /// + /// /// /// Thrown when type or typeNameConverters is null /// Thrown when collection element type for the passed type is null (occurs only if the passed type is a collection type) - string GetTsTypeName(Type type, bool forTypeDeclaration = false); + string GetTsTypeName(Type type, bool forTypeDeclaration = false, Action typeIsBlacklistedCallback = null); /// /// Gets the TypeScript type name to generate for a member /// /// + /// /// - string GetTsTypeName(MemberInfo memberInfo); + string GetTsTypeName(MemberInfo memberInfo, Action typeIsBlacklistedCallback = null); /// /// Gets the type of the deepest element from a jagged collection of the given type. @@ -126,6 +128,6 @@ internal interface ITypeService bool UseDefaultExport(Type type); IEnumerable GetTypeUnions(MemberInfo memberInfo); - IEnumerable GetInterfaces(Type type); + IEnumerable GetImplementedInterfaces(Type type); } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/Generator/Services/TsContentGenerator.cs b/src/TypeGen/TypeGen.Core/Generator/Services/TsContentGenerator.cs index cc8d66b7..490ee4fe 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Services/TsContentGenerator.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Services/TsContentGenerator.cs @@ -112,7 +112,7 @@ public string GetExtendsForInterfacesText(Type type) Requires.NotNull(type, nameof(type)); Requires.NotNull(GeneratorOptions.TypeNameConverters, nameof(GeneratorOptions.TypeNameConverters)); - IEnumerable baseTypes = _typeService.GetInterfaces(type); + IEnumerable baseTypes = _typeService.GetImplementedInterfaces(type); if (!baseTypes.Any()) return ""; IEnumerable baseTypeNames = baseTypes.Select(baseType => _typeService.GetTsTypeName(baseType, true)); @@ -129,10 +129,10 @@ public string GetImplementsText(Type type) Requires.NotNull(type, nameof(type)); Requires.NotNull(GeneratorOptions.TypeNameConverters, nameof(GeneratorOptions.TypeNameConverters)); - IEnumerable baseTypes = _typeService.GetInterfaces(type); - if (!baseTypes.Any()) return ""; + IEnumerable implementedInterfaces = _typeService.GetImplementedInterfaces(type); + if (!implementedInterfaces.Any()) return ""; - IEnumerable baseTypeNames = baseTypes.Select(baseType => _typeService.GetTsTypeName(baseType, true)); + IEnumerable baseTypeNames = implementedInterfaces.Select(baseType => _typeService.GetTsTypeName(baseType, true)); return _templateService.GetImplementsText(baseTypeNames); } diff --git a/src/TypeGen/TypeGen.Core/Generator/Services/TypeDependencyService.cs b/src/TypeGen/TypeGen.Core/Generator/Services/TypeDependencyService.cs index f1dacb74..eb0e07c5 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Services/TypeDependencyService.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Services/TypeDependencyService.cs @@ -55,6 +55,7 @@ public IEnumerable GetTypeDependencies(Type type) .Concat(GetMemberTypeDependencies(type)) .Distinct(new TypeDependencyInfoTypeComparer()) .Where(t => t.Type != type) + .Where(t => GeneratorOptions.IsTypeNotBlacklisted(t.Type)) .ToList(); } @@ -112,7 +113,7 @@ private IEnumerable GetImplementedInterfaceTypesDependencies { if (_metadataReaderFactory.GetInstance().GetAttribute(type) != null) return Enumerable.Empty(); - var baseTypes = _typeService.GetInterfaces(type); + var baseTypes = _typeService.GetImplementedInterfaces(type); if (!baseTypes.Any()) return Enumerable.Empty(); return baseTypes diff --git a/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs b/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs index 8b2d7087..66a8f147 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs @@ -45,44 +45,45 @@ public bool IsEnumType(Type type) return type.IsEnum; } - private string GenerateCustomType(Type t, string customType) + private string ConstructTsTypeName(Type type, string tsTypeNameTemplate) { // For custom types mappings ending with <>, construct the relevant generic custom type - if (customType.EndsWith("<>")) + if (tsTypeNameTemplate.EndsWith("<>")) { - customType = customType.Substring(0, customType.Length - 2); // Strip <> - string[] genericArgumentNames = t.GetGenericArguments() + tsTypeNameTemplate = tsTypeNameTemplate.Substring(0, tsTypeNameTemplate.Length - 2); // Strip <> + string[] genericArgumentNames = type.GetGenericArguments() .Select(t2 => t2.IsGenericParameter ? t2.Name : GetTsTypeName(t2, false)) .ToArray(); - customType = $"{customType}<{string.Join(", ", genericArgumentNames)}>"; + tsTypeNameTemplate = $"{tsTypeNameTemplate}<{string.Join(", ", genericArgumentNames)}>"; } // For custom types not ending with <>, leave the custom type as-is (not generic) - return customType; + return tsTypeNameTemplate; } - private bool TryGetCustomTypeMapping(Type t, out string customType) + private bool TryGetCustomTypeMapping(Type type, out string tsTypeName) { - if (t != null && t.FullName != null && GeneratorOptions.CustomTypeMappings != null) + if (type is { FullName: not null } && GeneratorOptions.CustomTypeMappings != null) { // Check for given type as-is (and combined generics) - if (GeneratorOptions.CustomTypeMappings.TryGetValue(t.FullName, out string customTypeMappingValue)) + if (GeneratorOptions.CustomTypeMappings.TryGetValue(type.FullName, out var customTypeMappingValue)) { - customType = GenerateCustomType(t, customTypeMappingValue); + tsTypeName = ConstructTsTypeName(type, customTypeMappingValue); return true; } - else if (t.IsConstructedGenericType) + + if (type.IsConstructedGenericType) { // Check for generic type - Type genericType = t.GetGenericTypeDefinition(); + Type genericType = type.GetGenericTypeDefinition(); if (GeneratorOptions.CustomTypeMappings.TryGetValue(genericType.FullName, out customTypeMappingValue)) { - customType = GenerateCustomType(t, customTypeMappingValue); + tsTypeName = ConstructTsTypeName(type, customTypeMappingValue); return true; } } } - customType = null; + tsTypeName = null; return false; } @@ -157,9 +158,7 @@ public Type GetMemberType(MemberInfo memberInfo) Requires.NotNull(memberInfo, nameof(memberInfo)); if (!memberInfo.Is() && !memberInfo.Is()) - { throw new ArgumentException($"{memberInfo} must be either a FieldInfo or a PropertyInfo"); - } return memberInfo is PropertyInfo info ? StripNullable(info.PropertyType) @@ -208,49 +207,28 @@ public bool UseDefaultExport(Type type) } /// - public string GetTsTypeName(Type type, bool forTypeDeclaration = false) + public string GetTsTypeName(Type type, bool forTypeDeclaration = false, Action typeIsBlacklistedCallback = null) { Requires.NotNull(type, nameof(type)); Requires.NotNull(GeneratorOptions.TypeNameConverters, nameof(GeneratorOptions.TypeNameConverters)); type = StripNullable(type); - if (TryGetCustomTypeMapping(type, out string customType)) - { - return customType; - } - - // handle simple types - if (IsTsBuiltInType(type)) - { - return GetTsBuiltInTypeName(type); - } - - // handle collection types - if (IsCollectionType(type)) - { - return GetTsCollectionTypeName(type); - } - - // handle dictionaries - if (IsDictionaryType(type)) - { - return GetTsDictionaryTypeName(type); - } + if (TryGetCustomTypeMapping(type, out string customType)) return customType; + + if (GeneratorOptions.IsTypeBlacklisted(type)) typeIsBlacklistedCallback?.Invoke(type); - // handle custom generic types - if (IsCustomGenericType(type)) - { - return GetGenericTsTypeName(type, forTypeDeclaration); - } + if (IsTsBuiltInType(type)) return GetTsBuiltInTypeName(type); + if (IsCollectionType(type)) return GetTsCollectionTypeName(type); + if (IsDictionaryType(type)) return GetTsDictionaryTypeName(type); + if (IsCustomGenericType(type)) return GetGenericTsTypeName(type, forTypeDeclaration); - // handle custom types & generic parameters string typeNameNoArity = type.Name.RemoveTypeArity(); return type.IsGenericParameter ? typeNameNoArity : GeneratorOptions.TypeNameConverters.Convert(typeNameNoArity, type); } /// - public string GetTsTypeName(MemberInfo memberInfo) + public string GetTsTypeName(MemberInfo memberInfo, Action typeIsBlacklistedCallback = null) { Requires.NotNull(memberInfo, nameof(memberInfo)); Requires.NotNull(GeneratorOptions.TypeNameConverters, nameof(GeneratorOptions.TypeNameConverters)); @@ -259,36 +237,29 @@ public string GetTsTypeName(MemberInfo memberInfo) if (typeAttribute != null) { if (string.IsNullOrWhiteSpace(typeAttribute.TypeName)) - { throw new CoreException($"No type specified in TsType attribute for member '{memberInfo.Name}' declared in '{memberInfo.DeclaringType?.FullName}'"); - } Type type = GetMemberType(memberInfo); - return GenerateCustomType(type, typeAttribute.TypeName); + return ConstructTsTypeName(type, typeAttribute.TypeName); } - return GetTsTypeNameForMember(memberInfo); + return GetTsTypeNameForMember(memberInfo, typeIsBlacklistedCallback); } /// /// Gets TypeScript type name for a member /// /// + /// /// /// Thrown when member or typeNameConverters is null - private string GetTsTypeNameForMember(MemberInfo memberInfo) + private string GetTsTypeNameForMember(MemberInfo memberInfo, Action typeIsBlacklistedCallback = null) { - // special case - dynamic property/field - if (memberInfo.GetCustomAttribute() != null) - { return "any"; - } - - // otherwise, resolve by type Type type = GetMemberType(memberInfo); - return GetTsTypeName(type); + return GetTsTypeName(type, false, typeIsBlacklistedCallback); } #if NET6_0_OR_GREATER @@ -542,7 +513,7 @@ public Type GetBaseType(Type type) Requires.NotNull(type, nameof(type)); Type baseType = type.GetTypeInfo().BaseType; - if (baseType == null || baseType == typeof(object)) return null; + if (baseType == null || baseType == typeof(object) || GeneratorOptions.IsTypeBlacklisted(baseType)) return null; if (IsTsClass(type) && IsTsInterface(baseType)) throw new CoreException($"Attempted to generate class '{type.FullName}' which extends an interface '{baseType.FullName}', which is not a valid inheritance chain in TypeScript"); @@ -550,15 +521,11 @@ public Type GetBaseType(Type type) } /// - public IEnumerable GetInterfaces(Type type) + public IEnumerable GetImplementedInterfaces(Type type) { Requires.NotNull(type, nameof(type)); - - IEnumerable baseTypes = type.GetTypeInfo().ImplementedInterfaces; - - // if (IsTsClass(type) && IsTsInterface(baseType)) throw new CoreException($"Attempted to generate class '{type.FullName}' which extends an interface '{baseType.FullName}', which is not a valid inheritance chain in TypeScript"); - - return baseTypes; + return type.GetTypeInfo().ImplementedInterfaces + .Where(GeneratorOptions.IsTypeNotBlacklisted); } } } diff --git a/src/TypeGen/TypeGen.Core/SpecGeneration/GenerationSpec.cs b/src/TypeGen/TypeGen.Core/SpecGeneration/GenerationSpec.cs index 8d984ac8..f21cec13 100644 --- a/src/TypeGen/TypeGen.Core/SpecGeneration/GenerationSpec.cs +++ b/src/TypeGen/TypeGen.Core/SpecGeneration/GenerationSpec.cs @@ -1,7 +1,9 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Reflection; +using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration.Builders; using TypeGen.Core.SpecGeneration.Builders.Generic; using TypeGen.Core.TypeAnnotations; From 9d4654806c842dd00e1aeb83a57cd1c02b4a0fb3 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Wed, 23 Aug 2023 21:29:24 +0200 Subject: [PATCH 07/16] added integration tests for type blacklist --- .../TypeGen.Core/Generator/Generator.cs | 9 +- .../Generator/GeneratorOptions.cs | 5 +- .../Generator/Services/ITypeService.cs | 10 +- .../Services/TypeDependencyService.cs | 2 +- .../Generator/Services/TypeService.cs | 57 +++++-- .../Blacklist/BlacklistTest.cs | 148 ++++++++++++++++++ .../Blacklist/Entities/Bar.cs | 6 + .../Blacklist/Entities/Baz.cs | 6 + .../Entities/ClassWithBlacklistedBase.cs | 9 ++ .../Entities/ClassWithBlacklistedInterface.cs | 9 ++ .../ClassWithBlacklistedPropertyType.cs | 9 ++ .../ClassWithBlacklistedTypeInArray.cs | 10 ++ ...ClassWithBlacklistedTypeInCustomGeneric.cs | 10 ++ .../ClassWithBlacklistedTypeInDictionary.cs | 10 ++ .../Blacklist/Entities/CustomGeneric.cs | 6 + .../Blacklist/Entities/IFoo.cs | 6 + .../Entities/InterfaceWithBlacklistedBase.cs | 9 ++ .../InterfaceWithBlacklistedPropertyType.cs | 9 ++ .../Expected/class-with-blacklisted-base.ts | 9 ++ .../class-with-blacklisted-interface.ts | 9 ++ .../interface-with-blacklisted-base.ts | 7 + .../TestingUtils/GenerationTestBase.cs | 11 +- .../TypeGen.IntegrationTest.csproj | 3 + 23 files changed, 338 insertions(+), 31 deletions(-) create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Bar.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Baz.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedBase.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedInterface.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/CustomGeneric.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/IFoo.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedBase.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-base.ts create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-interface.ts create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/interface-with-blacklisted-base.ts diff --git a/src/TypeGen/TypeGen.Core/Generator/Generator.cs b/src/TypeGen/TypeGen.Core/Generator/Generator.cs index 729cbf50..7d371121 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Generator.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Generator.cs @@ -546,6 +546,7 @@ private bool IsReadonlyTsProperty(MemberInfo memberInfo) private string GetClassPropertyText(Type type, MemberInfo memberInfo) { LogClassPropertyWarnings(memberInfo); + if (_typeService.MemberTypeContainsBlacklistedType(memberInfo)) ThrowMemberTypeIsBlacklisted(memberInfo); string modifiers = Options.ExplicitPublicAccessor ? "public " : ""; @@ -554,7 +555,7 @@ private string GetClassPropertyText(Type type, MemberInfo memberInfo) var nameAttribute = _metadataReaderFactory.GetInstance().GetAttribute(memberInfo); string name = nameAttribute?.Name ?? Options.PropertyNameConverters.Convert(memberInfo.Name, memberInfo); - string typeName = _typeService.GetTsTypeName(memberInfo, MemberTypeIsBlacklistedCallback(memberInfo)); + string typeName = _typeService.GetTsTypeName(memberInfo); IEnumerable typeUnions = _typeService.GetTypeUnions(memberInfo); var tsDoc = GetTsDocForMember(type, memberInfo); @@ -582,10 +583,9 @@ private string GetClassPropertyText(Type type, MemberInfo memberInfo) return _templateService.FillClassPropertyTemplate(modifiers, name, typeName, typeUnions, isOptional, tsDoc); } - private static Action MemberTypeIsBlacklistedCallback(MemberInfo memberInfo) + private static Action ThrowMemberTypeIsBlacklisted(MemberInfo memberInfo) { - return type => throw new CoreException($"Type '{type.FullName}'" + - $" used for member '{memberInfo.DeclaringType.FullName}.{memberInfo.Name}'" + + throw new CoreException($"Member '{memberInfo.DeclaringType.FullName}.{memberInfo.Name}'" + $" contains a blacklisted type. Possible solutions:" + $"{Environment.NewLine}1. Remove the type from blacklist." + $"{Environment.NewLine}2. Remove the member." + @@ -649,6 +649,7 @@ private string GetClassPropertiesText(Type type) private string GetInterfacePropertyText(Type type, MemberInfo memberInfo) { LogInterfacePropertyWarnings(memberInfo); + if (_typeService.MemberTypeContainsBlacklistedType(memberInfo)) ThrowMemberTypeIsBlacklisted(memberInfo); string modifiers = ""; if (IsReadonlyTsProperty(memberInfo)) modifiers += "readonly "; diff --git a/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs b/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs index 35b3c063..1aaacd4f 100644 --- a/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs +++ b/src/TypeGen/TypeGen.Core/Generator/GeneratorOptions.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Runtime.Serialization; using TypeGen.Core.Converters; using TypeGen.Core.Extensions; using TypeGen.Core.Generator.Services; @@ -48,8 +49,10 @@ public class GeneratorOptions typeof(IEquatable<>).FullName, typeof(IFormattable).FullName, "System.IParsable`1", + typeof(ISerializable).FullName, "System.ISpanFormattable", - "System.ISpanParsable`1" + "System.ISpanParsable`1", + typeof(ValueType).FullName }); /// diff --git a/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs b/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs index 6063d374..f687a9dd 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs @@ -72,26 +72,24 @@ internal interface ITypeService /// /// /// - bool IsIngoredGenericConstarint(Type type); + bool IsIgnoredGenericConstarint(Type type); /// /// Gets TypeScript type name for a type /// /// /// - /// /// /// Thrown when type or typeNameConverters is null /// Thrown when collection element type for the passed type is null (occurs only if the passed type is a collection type) - string GetTsTypeName(Type type, bool forTypeDeclaration = false, Action typeIsBlacklistedCallback = null); + string GetTsTypeName(Type type, bool forTypeDeclaration = false); /// /// Gets the TypeScript type name to generate for a member /// /// - /// /// - string GetTsTypeName(MemberInfo memberInfo, Action typeIsBlacklistedCallback = null); + string GetTsTypeName(MemberInfo memberInfo); /// /// Gets the type of the deepest element from a jagged collection of the given type. @@ -129,5 +127,7 @@ internal interface ITypeService IEnumerable GetTypeUnions(MemberInfo memberInfo); IEnumerable GetImplementedInterfaces(Type type); + bool TypeContainsBlacklistedType(Type type); + bool MemberTypeContainsBlacklistedType(MemberInfo memberInfo); } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/Generator/Services/TypeDependencyService.cs b/src/TypeGen/TypeGen.Core/Generator/Services/TypeDependencyService.cs index eb0e07c5..d1932d24 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Services/TypeDependencyService.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Services/TypeDependencyService.cs @@ -77,7 +77,7 @@ private IEnumerable GetGenericTypeDefinitionDependencies(Typ var stripped = _typeService.StripNullable(constraint); Type baseFlatType = _typeService.GetFlatType(stripped); - if (_typeService.IsIngoredGenericConstarint(baseFlatType)) + if (_typeService.IsIgnoredGenericConstarint(baseFlatType)) continue; result.AddRange(GetFlatTypeDependencies(baseFlatType)); diff --git a/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs b/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs index 66a8f147..3fbd60f7 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs @@ -15,7 +15,7 @@ namespace TypeGen.Core.Generator.Services /// internal class TypeService : ITypeService { - private static HashSet IgnoredGenricConstraints = new HashSet + private static HashSet IgnoredGenricConstraints = new() { typeof(ValueType) }; @@ -194,7 +194,7 @@ public bool IsCustomGenericType(Type type) } /// - public bool IsIngoredGenericConstarint(Type type) + public bool IsIgnoredGenericConstarint(Type type) { return IgnoredGenricConstraints.Contains(type); } @@ -207,7 +207,7 @@ public bool UseDefaultExport(Type type) } /// - public string GetTsTypeName(Type type, bool forTypeDeclaration = false, Action typeIsBlacklistedCallback = null) + public string GetTsTypeName(Type type, bool forTypeDeclaration = false) { Requires.NotNull(type, nameof(type)); Requires.NotNull(GeneratorOptions.TypeNameConverters, nameof(GeneratorOptions.TypeNameConverters)); @@ -216,8 +216,6 @@ public string GetTsTypeName(Type type, bool forTypeDeclaration = false, Action - public string GetTsTypeName(MemberInfo memberInfo, Action typeIsBlacklistedCallback = null) + public string GetTsTypeName(MemberInfo memberInfo) { Requires.NotNull(memberInfo, nameof(memberInfo)); Requires.NotNull(GeneratorOptions.TypeNameConverters, nameof(GeneratorOptions.TypeNameConverters)); @@ -243,23 +241,55 @@ public string GetTsTypeName(MemberInfo memberInfo, Action typeIsBlackliste return ConstructTsTypeName(type, typeAttribute.TypeName); } - return GetTsTypeNameForMember(memberInfo, typeIsBlacklistedCallback); + return GetTsTypeNameForMember(memberInfo); + } + + public bool MemberTypeContainsBlacklistedType(MemberInfo memberInfo) + { + Requires.NotNull(memberInfo, nameof(memberInfo)); + + var type = GetMemberType(memberInfo); + return TypeContainsBlacklistedType(type); + } + + public bool TypeContainsBlacklistedType(Type type) + { + Requires.NotNull(type, nameof(type)); + + if (type.IsGenericParameter) return false; + + type = StripNullable(type); + if (GeneratorOptions.IsTypeBlacklisted(type)) return true; + + if (IsCollectionType(type)) + { + var elementType = GetTsCollectionElementType(type); + if (GeneratorOptions.IsTypeBlacklisted(elementType)) return true; + } + + if (type.IsGenericType) + { + return type.GetGenericArguments() + .Select(TypeContainsBlacklistedType) + .Any(x => x); + } + + return false; } /// /// Gets TypeScript type name for a member /// /// - /// /// /// Thrown when member or typeNameConverters is null - private string GetTsTypeNameForMember(MemberInfo memberInfo, Action typeIsBlacklistedCallback = null) + private string GetTsTypeNameForMember(MemberInfo memberInfo) { if (memberInfo.GetCustomAttribute() != null) return "any"; Type type = GetMemberType(memberInfo); - return GetTsTypeName(type, false, typeIsBlacklistedCallback); + return GetTsTypeName(type, false); } #if NET6_0_OR_GREATER @@ -409,7 +439,7 @@ private string GetGenericTsTypeNameForDeclaration(Type type) /// private string GetGenericTsTypeConstraintsForDeclaration(Type type) { - var constraints = type.GetGenericParameterConstraints().Where(t => !IsIngoredGenericConstarint(t)).ToArray(); + var constraints = type.GetGenericParameterConstraints().Where(t => !IsIgnoredGenericConstarint(t)).ToArray(); if (constraints.Length < 1) return type.Name; @@ -458,8 +488,7 @@ private string GetGenericTsTypeNameDeclarationAgnostic(Type type, Func private Type GetTsCollectionElementType(Type type) { - // handle array types - Type elementType = type.GetElementType(); + Type elementType = type.GetElementType(); // this is for arrays if (elementType != null) { return StripNullable(elementType); @@ -467,10 +496,8 @@ private Type GetTsCollectionElementType(Type type) switch (type.Name) { - // handle IEnumerable<> case "IEnumerable`1": return StripNullable(type.GetGenericArguments()[0]); - // handle IEnumerable case "IEnumerable": return typeof(object); } diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs new file mode 100644 index 00000000..022842d7 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using FluentAssertions; +using TypeGen.Core; +using TypeGen.Core.Generator; +using TypeGen.Core.SpecGeneration; +using TypeGen.IntegrationTest.Blacklist.Entities; +using TypeGen.IntegrationTest.CircularGenericConstraint.TestClasses; +using TypeGen.IntegrationTest.TestingUtils; +using Xunit; + +namespace TypeGen.IntegrationTest.Blacklist +{ + public class BlacklistTest : GenerationTestBase + { + [Fact] + public async Task ClassWithBlacklistedBase_Test() + { + var type = typeof(ClassWithBlacklistedBase); + const string expectedLocation = "TypeGen.IntegrationTest.Blacklist.Expected.class-with-blacklisted-base.ts"; + var blacklist = new HashSet { typeof(Bar).FullName }; + var generationSpec = new ClassWithBlacklistedBaseGenerationSpec(); + var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; + + await TestGenerationSpec(type, expectedLocation, generationSpec, generatorOptions); + } + + [Fact] + public async Task ClassWithBlacklistedInterface_Test() + { + var type = typeof(ClassWithBlacklistedInterface); + const string expectedLocation = "TypeGen.IntegrationTest.Blacklist.Expected.class-with-blacklisted-interface.ts"; + var blacklist = new HashSet { typeof(IFoo).FullName }; + var generationSpec = new ClassWithBlacklistedInterfaceGenerationSpec(); + var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; + + await TestGenerationSpec(type, expectedLocation, generationSpec, generatorOptions); + } + + [Fact] + public async Task InterfaceWithBlacklistedBase_Test() + { + var type = typeof(InterfaceWithBlacklistedBase); + const string expectedLocation = "TypeGen.IntegrationTest.Blacklist.Expected.interface-with-blacklisted-base.ts"; + var blacklist = new HashSet { typeof(IFoo).FullName }; + var generationSpec = new InterfaceWithBlacklistedBaseGenerationSpec(); + var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; + + await TestGenerationSpec(type, expectedLocation, generationSpec, generatorOptions); + } + + [Fact] + public void ClassWithBlacklistedPropertyType_Test() + { + var blacklist = new HashSet { typeof(Baz).FullName }; + var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; + var generator = new Generator(generatorOptions); + var generationSpec = new ClassWithBlacklistedPropertyTypeGenerationSpec(); + + ((Action)(() => generator.Generate(new[] { generationSpec }))).Should().Throw(); + } + + [Fact] + public void ClassWithBlacklistedTypeInDictionary_Test() + { + var blacklist = new HashSet { typeof(Baz).FullName }; + var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; + var generator = new Generator(generatorOptions); + var generationSpec = new ClassWithBlacklistedTypeInDictionaryGenerationSpec(); + + ((Action)(() => generator.Generate(new[] { generationSpec }))).Should().Throw(); + } + + [Fact] + public void ClassWithBlacklistedTypeInArray_Test() + { + var blacklist = new HashSet { typeof(Baz).FullName }; + var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; + var generator = new Generator(generatorOptions); + var generationSpec = new ClassWithBlacklistedTypeInArrayGenerationSpec(); + + ((Action)(() => generator.Generate(new[] { generationSpec }))).Should().Throw(); + } + + [Fact] + public void ClassWithBlacklistedTypeInCustomGeneric_Test() + { + var blacklist = new HashSet { typeof(Baz).FullName }; + var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; + var generator = new Generator(generatorOptions); + var generationSpec = new ClassWithBlacklistedTypeInCustomGenericGenerationSpec(); + + ((Action)(() => generator.Generate(new[] { generationSpec }))).Should().Throw(); + } + + [Fact] + public void InterfaceWithBlacklistedPropertyType_Test() + { + var blacklist = new HashSet { typeof(Baz).FullName }; + var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; + var generator = new Generator(generatorOptions); + var generationSpec = new InterfaceWithBlacklistedPropertyTypeGenerationSpec(); + + ((Action)(() => generator.Generate(new[] { generationSpec }))).Should().Throw(); + } + + private class ClassWithBlacklistedBaseGenerationSpec : GenerationSpec + { + public ClassWithBlacklistedBaseGenerationSpec() => AddClass(); + } + + private class ClassWithBlacklistedInterfaceGenerationSpec : GenerationSpec + { + public ClassWithBlacklistedInterfaceGenerationSpec() => AddClass(); + } + + private class InterfaceWithBlacklistedBaseGenerationSpec : GenerationSpec + { + public InterfaceWithBlacklistedBaseGenerationSpec() => AddInterface(); + } + + private class ClassWithBlacklistedPropertyTypeGenerationSpec : GenerationSpec + { + public ClassWithBlacklistedPropertyTypeGenerationSpec() => AddClass(); + } + + private class ClassWithBlacklistedTypeInDictionaryGenerationSpec : GenerationSpec + { + public ClassWithBlacklistedTypeInDictionaryGenerationSpec() => AddClass(); + } + + private class ClassWithBlacklistedTypeInArrayGenerationSpec : GenerationSpec + { + public ClassWithBlacklistedTypeInArrayGenerationSpec() => AddClass(); + } + + private class ClassWithBlacklistedTypeInCustomGenericGenerationSpec : GenerationSpec + { + public ClassWithBlacklistedTypeInCustomGenericGenerationSpec() => AddClass(); + } + + private class InterfaceWithBlacklistedPropertyTypeGenerationSpec : GenerationSpec + { + public InterfaceWithBlacklistedPropertyTypeGenerationSpec() => AddClass(); + } + } +} diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Bar.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Bar.cs new file mode 100644 index 00000000..f1fb285c --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Bar.cs @@ -0,0 +1,6 @@ +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +public class Bar +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Baz.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Baz.cs new file mode 100644 index 00000000..f484f56f --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Baz.cs @@ -0,0 +1,6 @@ +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +public class Baz +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedBase.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedBase.cs new file mode 100644 index 00000000..044ed8c7 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedBase.cs @@ -0,0 +1,9 @@ +using TypeGen.Core.TypeAnnotations; + +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +[ExportTsClass] +public class ClassWithBlacklistedBase : Bar, IFoo +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedInterface.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedInterface.cs new file mode 100644 index 00000000..1adadef2 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedInterface.cs @@ -0,0 +1,9 @@ +using TypeGen.Core.TypeAnnotations; + +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +[ExportTsClass] +public class ClassWithBlacklistedInterface : Bar, IFoo +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs new file mode 100644 index 00000000..0b5521ff --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs @@ -0,0 +1,9 @@ +using TypeGen.Core.TypeAnnotations; + +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +[ExportTsClass] +public class ClassWithBlacklistedPropertyType +{ + public Baz BazProp { get; set; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs new file mode 100644 index 00000000..fdc8735d --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using TypeGen.Core.TypeAnnotations; + +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +[ExportTsClass] +public class ClassWithBlacklistedTypeInArray +{ + public Baz[] BazProp { get; set; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs new file mode 100644 index 00000000..e8180ec7 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs @@ -0,0 +1,10 @@ +using System; +using TypeGen.Core.TypeAnnotations; + +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +[ExportTsClass] +public class ClassWithBlacklistedTypeInCustomGeneric +{ + public CustomGeneric, DateTime> BazProp { get; set; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs new file mode 100644 index 00000000..c3348331 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; +using TypeGen.Core.TypeAnnotations; + +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +[ExportTsClass] +public class ClassWithBlacklistedTypeInDictionary +{ + public IDictionary BazProp { get; set; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/CustomGeneric.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/CustomGeneric.cs new file mode 100644 index 00000000..7ace6854 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/CustomGeneric.cs @@ -0,0 +1,6 @@ +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +public class CustomGeneric +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/IFoo.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/IFoo.cs new file mode 100644 index 00000000..2897be96 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/IFoo.cs @@ -0,0 +1,6 @@ +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +public interface IFoo +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedBase.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedBase.cs new file mode 100644 index 00000000..39012a5a --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedBase.cs @@ -0,0 +1,9 @@ +using TypeGen.Core.TypeAnnotations; + +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +[ExportTsInterface] +public interface InterfaceWithBlacklistedBase : IFoo +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs new file mode 100644 index 00000000..fedb95a1 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs @@ -0,0 +1,9 @@ +using TypeGen.Core.TypeAnnotations; + +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +[ExportTsInterface] +public interface InterfaceWithBlacklistedPropertyType +{ + Baz BazProp { get; set; } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-base.ts b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-base.ts new file mode 100644 index 00000000..9b255a1e --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-base.ts @@ -0,0 +1,9 @@ +/** + * This is a TypeGen auto-generated file. + * Any changes made to this file can be lost when this file is regenerated. + */ + +import { IFoo } from "./i-foo"; + +export class ClassWithBlacklistedBase implements IFoo { +} diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-interface.ts b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-interface.ts new file mode 100644 index 00000000..3f7738ad --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-interface.ts @@ -0,0 +1,9 @@ +/** + * This is a TypeGen auto-generated file. + * Any changes made to this file can be lost when this file is regenerated. + */ + +import { Bar } from "./bar"; + +export class ClassWithBlacklistedInterface extends Bar { +} diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/interface-with-blacklisted-base.ts b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/interface-with-blacklisted-base.ts new file mode 100644 index 00000000..a436dd8a --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/interface-with-blacklisted-base.ts @@ -0,0 +1,7 @@ +/** + * This is a TypeGen auto-generated file. + * Any changes made to this file can be lost when this file is regenerated. + */ + +export interface InterfaceWithBlacklistedBase { +} diff --git a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs b/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs index c7933e43..42d16365 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs +++ b/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using FluentAssertions; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; using TypeGen.IntegrationTest.Extensions; @@ -19,21 +20,21 @@ protected async Task TestFromAssembly(Type type, string expectedLocation) await generator.GenerateAsync(type.Assembly); var expected = (await readExpectedTask).Trim(); - Assert.True(interceptor.GeneratedOutputs.ContainsKey(type)); - Assert.Equal(expected, interceptor.GeneratedOutputs[type].Content.FormatOutput()); + interceptor.GeneratedOutputs.Should().ContainKey(type); + interceptor.GeneratedOutputs[type].Content.FormatOutput().Should().Be(expected); } protected static async Task TestGenerationSpec(Type type, string expectedLocation, GenerationSpec generationSpec, GeneratorOptions generatorOptions) { var readExpectedTask = EmbededResourceReader.GetEmbeddedResourceAsync(expectedLocation); - var generator = new Core.Generator.Generator(generatorOptions); + var generator = new Generator(generatorOptions); var interceptor = GeneratorOutputInterceptor.CreateInterceptor(generator); await generator.GenerateAsync(new[] { generationSpec }); var expected = (await readExpectedTask).Trim(); - Assert.True(interceptor.GeneratedOutputs.ContainsKey(type)); - Assert.Equal(expected, interceptor.GeneratedOutputs[type].Content.FormatOutput()); + interceptor.GeneratedOutputs.Should().ContainKey(type); + interceptor.GeneratedOutputs[type].Content.FormatOutput().Should().Be(expected); } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj b/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj index 7751ea29..b92b0766 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj +++ b/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj @@ -32,6 +32,9 @@ + + + From b8f41f25866fd6ca6f422244d7c4cf4f694d1e70 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Fri, 25 Aug 2023 23:46:51 +0200 Subject: [PATCH 08/16] added type whitelist/blacklist functionality cont. --- .../Business/GeneratorOptionsProviderTest.cs | 72 +++++++++++++++++++ .../TypeGen.Cli.Test/Models/TgConfigTest.cs | 31 ++++---- .../Business/GeneratorOptionsProvider.cs | 22 +++--- .../TypeGen.Cli/Business/ITypeResolver.cs | 9 +++ .../TypeGen.Cli/Business/TypeResolver.cs | 2 +- src/TypeGen/TypeGen.Cli/Models/TgConfig.cs | 6 ++ src/TypeGen/TypeGen.Cli/Program.cs | 5 +- .../Extensions/StringExtensionsTest.cs | 10 +++ .../Generator/GeneratorOptionsTest.cs | 51 +++++++++++++ .../Blacklist/BlacklistTest.cs | 16 +++++ .../Blacklist/Entities/MyRecord.cs | 3 + .../Blacklist/Expected/my-record.ts | 7 ++ .../TypeGen.IntegrationTest.csproj | 1 + 13 files changed, 207 insertions(+), 28 deletions(-) create mode 100644 src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs create mode 100644 src/TypeGen/TypeGen.Cli/Business/ITypeResolver.cs create mode 100644 src/TypeGen/TypeGen.Core.Test/Generator/GeneratorOptionsTest.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/MyRecord.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/my-record.ts diff --git a/src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs b/src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs new file mode 100644 index 00000000..c8eda99b --- /dev/null +++ b/src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using FluentAssertions; +using NSubstitute; +using TypeGen.Cli.Business; +using TypeGen.Cli.Models; +using TypeGen.Core.Generator; +using Xunit; + +namespace TypeGen.Cli.Test.Business; + +public class GeneratorOptionsProviderTest +{ + [Fact] + public void GetGeneratorOptions_Should_ConcatenateBlacklists() + { + // arrange + const string projectFolder = "test"; + var tgConfigBlacklist = new[] { "MyType" }; + var tgConfig = GetDefaultTgConfigWithoutConverters(); + tgConfig.TypeBlacklist = tgConfigBlacklist; + var expected = GeneratorOptions.DefaultTypeBlacklist.Concat(tgConfigBlacklist); + + var typeResolver = Substitute.For(); + var sut = new GeneratorOptionsProvider(typeResolver); + + // act + var actual = sut.GetGeneratorOptions(tgConfig, Enumerable.Empty(), projectFolder) + .TypeBlacklist; + + // assert + actual.Should().BeEquivalentTo(expected); + } + + [Fact] + public void GetGeneratorOptions_WhitelistGiven_WhitelistRemovesTypesFromBlacklist() + { + // arrange + const string projectFolder = "test"; + var tgConfigBlacklist = new[] { "MyType" }; + var tgConfigWhitelist = new[] { typeof(IConvertible).FullName }; + var tgConfig = GetDefaultTgConfigWithoutConverters(); + tgConfig.TypeBlacklist = tgConfigBlacklist; + tgConfig.TypeWhitelist = tgConfigWhitelist; + var expected = GeneratorOptions.DefaultTypeBlacklist.Concat(tgConfigBlacklist).Except(tgConfigWhitelist); + + var typeResolver = Substitute.For(); + var sut = new GeneratorOptionsProvider(typeResolver); + + // act + var actual = sut.GetGeneratorOptions(tgConfig, Enumerable.Empty(), projectFolder) + .TypeBlacklist; + + // assert + actual.Should().BeEquivalentTo(expected); + } + + private static TgConfig GetDefaultTgConfigWithoutConverters() + { + var tgConfig = new TgConfig(); + tgConfig.MergeWithDefaultParams(); + tgConfig.FileNameConverters = Array.Empty(); + tgConfig.PropertyNameConverters = Array.Empty(); + tgConfig.TypeNameConverters = Array.Empty(); + tgConfig.EnumStringInitializersConverters = Array.Empty(); + tgConfig.EnumValueNameConverters = Array.Empty(); + + return tgConfig; + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs b/src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs index 1c7d2487..f1156c9f 100644 --- a/src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs +++ b/src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs @@ -1,4 +1,5 @@ using System.Linq; +using FluentAssertions; using TypeGen.Cli.Models; using TypeGen.Core; using Xunit; @@ -26,20 +27,22 @@ public void MergeWithDefaultParams_ParametersNull_DefaultValuesAssignedToParamet var tgConfig = new TgConfig(); tgConfig.MergeWithDefaultParams(); - Assert.Equal(new string[0], tgConfig.Assemblies); - Assert.False(tgConfig.ExplicitPublicAccessor); - Assert.False(tgConfig.SingleQuotes); - Assert.False(tgConfig.AddFilesToProject); - Assert.Equal("ts", tgConfig.TypeScriptFileExtension); - Assert.Equal(4, tgConfig.TabLength); - Assert.Equal(new [] { "PascalCaseToKebabCaseConverter" }, tgConfig.FileNameConverters); - Assert.Equal(new string[0], tgConfig.TypeNameConverters); - Assert.Equal(new[] { "PascalCaseToCamelCaseConverter" }, tgConfig.PropertyNameConverters); - Assert.Equal(new string[0], tgConfig.EnumValueNameConverters); - Assert.Equal(new string[0], tgConfig.ExternalAssemblyPaths); - Assert.False(tgConfig.CreateIndexFile); - Assert.Equal("", tgConfig.CsNullableTranslation); - Assert.Equal("", tgConfig.OutputPath); + tgConfig.Assemblies.Should().BeEmpty(); + tgConfig.ExplicitPublicAccessor.Should().BeFalse(); + tgConfig.SingleQuotes.Should().BeFalse(); + tgConfig.AddFilesToProject.Should().BeFalse(); + tgConfig.TypeScriptFileExtension.Should().Be("ts"); + tgConfig.TabLength.Should().Be(4); + tgConfig.FileNameConverters.Should().BeEquivalentTo("PascalCaseToKebabCaseConverter"); + tgConfig.TypeNameConverters.Should().BeEmpty(); + tgConfig.PropertyNameConverters.Should().BeEquivalentTo("PascalCaseToCamelCaseConverter"); + tgConfig.EnumValueNameConverters.Should().BeEmpty(); + tgConfig.ExternalAssemblyPaths.Should().BeEmpty(); + tgConfig.CreateIndexFile.Should().BeFalse(); + tgConfig.CsNullableTranslation.Should().BeEmpty(); + tgConfig.OutputPath.Should().BeEmpty(); + tgConfig.TypeBlacklist.Should().BeEmpty(); + tgConfig.TypeWhitelist.Should().BeEmpty(); } [Fact] diff --git a/src/TypeGen/TypeGen.Cli/Business/GeneratorOptionsProvider.cs b/src/TypeGen/TypeGen.Cli/Business/GeneratorOptionsProvider.cs index bc3fcad8..6d0a92aa 100644 --- a/src/TypeGen/TypeGen.Cli/Business/GeneratorOptionsProvider.cs +++ b/src/TypeGen/TypeGen.Cli/Business/GeneratorOptionsProvider.cs @@ -20,15 +20,11 @@ namespace TypeGen.Cli.Business { internal class GeneratorOptionsProvider : IGeneratorOptionsProvider { - private readonly IFileSystem _fileSystem; - private readonly ILogger _logger; + private readonly ITypeResolver _typeResolver; - private TypeResolver _typeResolver; - - public GeneratorOptionsProvider(IFileSystem fileSystem, ILogger logger) + public GeneratorOptionsProvider(ITypeResolver typeResolver) { - _fileSystem = fileSystem; - _logger = logger; + _typeResolver = typeResolver; } /// @@ -44,8 +40,6 @@ public GeneratorOptions GetGeneratorOptions(TgConfig config, IEnumerable GetTypeBlacklist(string[] configTypeBlacklist, string[] configTypeWhitelist) + { + var defaultBlacklist = GeneratorOptions.DefaultTypeBlacklist.ToArray(); + var blacklist = defaultBlacklist.Concat(configTypeBlacklist).Except(configTypeWhitelist); + return new HashSet(blacklist); + } + private TypeNameConverterCollection GetTypeNameConvertersFromConfig(IEnumerable typeNameConverters) { IEnumerable converters = GetConverters(typeNameConverters); diff --git a/src/TypeGen/TypeGen.Cli/Business/ITypeResolver.cs b/src/TypeGen/TypeGen.Cli/Business/ITypeResolver.cs new file mode 100644 index 00000000..e8dfaf67 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Business/ITypeResolver.cs @@ -0,0 +1,9 @@ +using System; +using System.Collections.Generic; + +namespace TypeGen.Cli.Business; + +internal interface ITypeResolver +{ + Type Resolve(string typeIdentifier, string typeNameSuffix = null, IEnumerable interfaceConstraints = null, IEnumerable baseTypeConstraints = null); +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Business/TypeResolver.cs b/src/TypeGen/TypeGen.Cli/Business/TypeResolver.cs index 4a8f0c4f..b72559fd 100644 --- a/src/TypeGen/TypeGen.Cli/Business/TypeResolver.cs +++ b/src/TypeGen/TypeGen.Cli/Business/TypeResolver.cs @@ -11,7 +11,7 @@ namespace TypeGen.Cli.Business { - internal class TypeResolver + internal class TypeResolver : ITypeResolver { private readonly ILogger _logger; private readonly IFileSystem _fileSystem; diff --git a/src/TypeGen/TypeGen.Cli/Models/TgConfig.cs b/src/TypeGen/TypeGen.Cli/Models/TgConfig.cs index c10bdd2a..67799ab1 100644 --- a/src/TypeGen/TypeGen.Cli/Models/TgConfig.cs +++ b/src/TypeGen/TypeGen.Cli/Models/TgConfig.cs @@ -18,6 +18,8 @@ internal class TgConfig public static bool DefaultAddFilesToProject => false; public static bool DefaultBuildProject => false; public static string DefaultProjectOutputFolder => "bin"; + public static string[] DefaultTypeBlacklist => Array.Empty(); + public static string[] DefaultTypeWhitelist => Array.Empty(); [Obsolete("Use Assemblies instead")] public string AssemblyPath { get; set; } @@ -52,6 +54,8 @@ internal class TgConfig public string ProjectOutputFolder { get; set; } public bool? ExportTypesAsInterfacesByDefault { get; set; } public bool? UseImportType { get; set; } + public string[] TypeBlacklist { get; set; } + public string[] TypeWhitelist { get; set; } public TgConfig Normalize() { @@ -98,6 +102,8 @@ public TgConfig MergeWithDefaultParams() if (ProjectOutputFolder == null) ProjectOutputFolder = DefaultProjectOutputFolder; if (ExportTypesAsInterfacesByDefault == null) ExportTypesAsInterfacesByDefault = GeneratorOptions.DefaultExportTypesAsInterfacesByDefault; if (UseImportType == null) UseImportType = GeneratorOptions.DefaultUseImportType; + if (TypeBlacklist == null) TypeBlacklist = DefaultTypeBlacklist; + if (TypeWhitelist == null) TypeWhitelist = DefaultTypeWhitelist; return this; } diff --git a/src/TypeGen/TypeGen.Cli/Program.cs b/src/TypeGen/TypeGen.Cli/Program.cs index 58abcece..e1d4b121 100644 --- a/src/TypeGen/TypeGen.Cli/Program.cs +++ b/src/TypeGen/TypeGen.Cli/Program.cs @@ -34,7 +34,6 @@ private static void InitializeServices(string[] args) _fileSystem = new FileSystem(); _configProvider = new ConfigProvider(_fileSystem, _logger); - _generatorOptionsProvider = new GeneratorOptionsProvider(_fileSystem, _logger); _projectFileManager = new ProjectFileManager(_fileSystem); _projectBuilder = new ProjectBuilder(_logger); } @@ -121,6 +120,8 @@ private static void Generate(string projectFolder, string configPath, string? ou // create generator + var typeResolver = new TypeResolver(_logger, _fileSystem, projectFolder, assemblies); + _generatorOptionsProvider = new GeneratorOptionsProvider(typeResolver); GeneratorOptions generatorOptions = _generatorOptionsProvider.GetGeneratorOptions(config, assemblies, projectFolder); generatorOptions.BaseOutputDirectory = outputFolder ?? Path.Combine(projectFolder, config.OutputPath); var generator = new Generator(generatorOptions, _logger); @@ -141,8 +142,6 @@ private static void Generate(string projectFolder, string configPath, string? ou if (config.GenerationSpecs.Any()) { - var typeResolver = new TypeResolver(_logger, _fileSystem, projectFolder, assemblies); - IEnumerable generationSpecs = config.GenerationSpecs .Select(name => typeResolver.Resolve(name, "GenerationSpec")) .Where(t => t != null) diff --git a/src/TypeGen/TypeGen.Core.Test/Extensions/StringExtensionsTest.cs b/src/TypeGen/TypeGen.Core.Test/Extensions/StringExtensionsTest.cs index dd57553b..97f49f4e 100644 --- a/src/TypeGen/TypeGen.Core.Test/Extensions/StringExtensionsTest.cs +++ b/src/TypeGen/TypeGen.Core.Test/Extensions/StringExtensionsTest.cs @@ -57,6 +57,16 @@ public void RemoveTypeGenericComponent_Test(string input, string expectedResult) Assert.Equal(expectedResult, actualResult); } + [Theory] + [InlineData("Foo.Bar.Baz", "Foo.Bar.Baz")] + [InlineData("Foo.Bar.Baz`2", "Foo.Bar.Baz`2")] + [InlineData("Foo.Bar.Baz`2[[System.Int32, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]", "Foo.Bar.Baz`2")] + public void RemoveGenericArgumentsFromTypeName_Test(string input, string expectedResult) + { + string actualResult = input.RemoveGenericArgumentsFromTypeName(); + Assert.Equal(expectedResult, actualResult); + } + [Theory] [InlineData("string", 0, "string")] [InlineData("string | null", 0, "string")] diff --git a/src/TypeGen/TypeGen.Core.Test/Generator/GeneratorOptionsTest.cs b/src/TypeGen/TypeGen.Core.Test/Generator/GeneratorOptionsTest.cs new file mode 100644 index 00000000..9121acd1 --- /dev/null +++ b/src/TypeGen/TypeGen.Core.Test/Generator/GeneratorOptionsTest.cs @@ -0,0 +1,51 @@ +using System; +using FluentAssertions; +using TypeGen.Core.Generator; +using Xunit; + +namespace TypeGen.Core.Test.Generator; + +public class GeneratorOptionsTest +{ + [Theory] + [InlineData(typeof(IConvertible), true)] + [InlineData(typeof(GeneratorOptionsTest), false)] + public void IsTypeBlacklisted_Test(Type type, bool expected) + { + var sut = new GeneratorOptions(); + sut.IsTypeBlacklisted(type).Should().Be(expected); + } + + [Theory] + [InlineData(typeof(IConvertible), false)] + [InlineData(typeof(GeneratorOptionsTest), true)] + public void IsTypeNotBlacklisted_Test(Type type, bool expected) + { + var sut = new GeneratorOptions(); + sut.IsTypeNotBlacklisted(type).Should().Be(expected); + } + + [Fact] + public void IsTypeBlacklisted_Should_MatchTypeFullName() + { + // arrange + var sut = new GeneratorOptions(); + sut.TypeBlacklist.Add(GetType().FullName); + + // act + // assert + sut.IsTypeBlacklisted(GetType()).Should().BeTrue(); + } + + [Fact] + public void IsTypeBlacklisted_Should_MatchTypeName() + { + // arrange + var sut = new GeneratorOptions(); + sut.TypeBlacklist.Add(GetType().Name); + + // act + // assert + sut.IsTypeBlacklisted(GetType()).Should().BeTrue(); + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs index 022842d7..8ed39abc 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs @@ -104,6 +104,17 @@ public void InterfaceWithBlacklistedPropertyType_Test() ((Action)(() => generator.Generate(new[] { generationSpec }))).Should().Throw(); } + + [Fact] + public async Task Record_Test() + { + var type = typeof(MyRecord); + const string expectedLocation = "TypeGen.IntegrationTest.Blacklist.Expected.my-record.ts"; + var generationSpec = new RecordGenerationSpec(); + var generatorOptions = new GeneratorOptions(); + + await TestGenerationSpec(type, expectedLocation, generationSpec, generatorOptions); + } private class ClassWithBlacklistedBaseGenerationSpec : GenerationSpec { @@ -144,5 +155,10 @@ private class InterfaceWithBlacklistedPropertyTypeGenerationSpec : GenerationSpe { public InterfaceWithBlacklistedPropertyTypeGenerationSpec() => AddClass(); } + + private class RecordGenerationSpec : GenerationSpec + { + public RecordGenerationSpec() => AddClass(); + } } } diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/MyRecord.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/MyRecord.cs new file mode 100644 index 00000000..be551329 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/MyRecord.cs @@ -0,0 +1,3 @@ +namespace TypeGen.IntegrationTest.Blacklist.Entities; + +public record MyRecord(); \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/my-record.ts b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/my-record.ts new file mode 100644 index 00000000..ef75d2df --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/my-record.ts @@ -0,0 +1,7 @@ +/** + * This is a TypeGen auto-generated file. + * Any changes made to this file can be lost when this file is regenerated. + */ + +export class MyRecord { +} diff --git a/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj b/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj index b92b0766..02b25074 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj +++ b/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj @@ -35,6 +35,7 @@ + From 19ff784e56d854011c96fc919cecb53a4aaddc44 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Sat, 26 Aug 2023 01:23:53 +0200 Subject: [PATCH 09/16] it is now possible to specify a TS interface base class for a TS class class --- .../Generator/Services/TypeServiceTest.cs | 12 ----- .../TypeGen.Core/Generator/Generator.cs | 2 +- .../Generator/Services/ITypeService.cs | 8 ---- .../Generator/Services/TypeService.cs | 45 +++++++++---------- .../Blacklist/BlacklistTest.cs | 1 - .../CircularGenericConstraintTest.cs | 2 +- .../{TestClasses => Entities}/TestClasses.cs | 2 +- .../DefaultExport/DefaultExportTest.cs | 1 - .../Extensions/StringExtensions.cs | 5 ++- .../TestingUtils/EmbededResourceReader.cs | 23 ++++------ .../TestingUtils/GenerationTestBase.cs | 8 ++-- .../Entities/TsClass.cs | 5 +++ .../Entities/TsInterface.cs | 6 +++ .../Expected/ts-class.ts | 9 ++++ .../TsClassExtendsTsInterfaceTest.cs | 31 +++++++++++++ .../TypeGen.IntegrationTest.csproj | 1 + 16 files changed, 91 insertions(+), 70 deletions(-) rename src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/{TestClasses => Entities}/TestClasses.cs (94%) create mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsClass.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsInterface.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Expected/ts-class.ts create mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs diff --git a/src/TypeGen/TypeGen.Core.Test/Generator/Services/TypeServiceTest.cs b/src/TypeGen/TypeGen.Core.Test/Generator/Services/TypeServiceTest.cs index effcfcf5..7290a9c0 100644 --- a/src/TypeGen/TypeGen.Core.Test/Generator/Services/TypeServiceTest.cs +++ b/src/TypeGen/TypeGen.Core.Test/Generator/Services/TypeServiceTest.cs @@ -98,18 +98,6 @@ public void GetTsBuiltInTypeName_TypeGiven_TsBuiltInTypeNameReturned(Type type, Assert.Equal(expectedResult, actualResult); } - [Theory] - [InlineData(typeof(MyClass), true)] - [InlineData(typeof(MyEnum), false)] - [InlineData(typeof(TsClass), true)] - [InlineData(typeof(TsInterface), false)] - [InlineData(typeof(TsEnum), false)] - public void IsTsClass_TypeGiven_DeterminedIfTsClass(Type type, bool expectedResult) - { - bool actualResult = _typeService.IsTsClass(type); - Assert.Equal(expectedResult, actualResult); - } - [Theory] [InlineData(typeof(MyClass), false)] [InlineData(typeof(MyEnum), false)] diff --git a/src/TypeGen/TypeGen.Core/Generator/Generator.cs b/src/TypeGen/TypeGen.Core/Generator/Generator.cs index 7d371121..b43633d7 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Generator.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Generator.cs @@ -583,7 +583,7 @@ private string GetClassPropertyText(Type type, MemberInfo memberInfo) return _templateService.FillClassPropertyTemplate(modifiers, name, typeName, typeUnions, isOptional, tsDoc); } - private static Action ThrowMemberTypeIsBlacklisted(MemberInfo memberInfo) + private static void ThrowMemberTypeIsBlacklisted(MemberInfo memberInfo) { throw new CoreException($"Member '{memberInfo.DeclaringType.FullName}.{memberInfo.Name}'" + $" contains a blacklisted type. Possible solutions:" + diff --git a/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs b/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs index f687a9dd..f39856e7 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Services/ITypeService.cs @@ -20,14 +20,6 @@ internal interface ITypeService /// one of: object, bool, string, int, long, float, double, decimal; or any type specified in GeneratorOptions.CustomMappings /// TypeScript type name. Null if the passed type cannot be represented as a TypeScript simple type. string GetTsBuiltInTypeName(Type type); - - /// - /// Determines whether the type represents a TypeScript class - /// - /// - /// True if the type represents a TypeScript class; false otherwise - /// Thrown if the type is null - bool IsTsClass(Type type); /// /// Determines whether the type represents a TypeScript class diff --git a/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs b/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs index 3fbd60f7..4a9649b5 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Services/TypeService.cs @@ -127,29 +127,12 @@ public string GetTsBuiltInTypeName(Type type) return null; } } - - /// - public bool IsTsClass(Type type) - { - Requires.NotNull(type, nameof(type)); - TypeInfo typeInfo = type.GetTypeInfo(); - - if (!typeInfo.IsClass) return false; - - var exportAttribute = MetadataReader.GetAttribute(type); - return exportAttribute == null || exportAttribute is ExportTsClassAttribute; - } /// public bool IsTsInterface(Type type) { Requires.NotNull(type, nameof(type)); - TypeInfo typeInfo = type.GetTypeInfo(); - - if (!typeInfo.IsClass) return false; - - var exportAttribute = MetadataReader.GetAttribute(type); - return exportAttribute is ExportTsInterfaceAttribute; + return MetadataReader.GetAttribute(type) != null; } /// @@ -538,11 +521,10 @@ public Type StripNullable(Type type) public Type GetBaseType(Type type) { Requires.NotNull(type, nameof(type)); - - Type baseType = type.GetTypeInfo().BaseType; - if (baseType == null || baseType == typeof(object) || GeneratorOptions.IsTypeBlacklisted(baseType)) return null; - - if (IsTsClass(type) && IsTsInterface(baseType)) throw new CoreException($"Attempted to generate class '{type.FullName}' which extends an interface '{baseType.FullName}', which is not a valid inheritance chain in TypeScript"); + var baseType = type.GetTypeInfo().BaseType; + + if (IsNullOrObjectOrBlacklisted(baseType) || IsTsInterface(baseType)) + return null; return baseType; } @@ -551,8 +533,23 @@ public Type GetBaseType(Type type) public IEnumerable GetImplementedInterfaces(Type type) { Requires.NotNull(type, nameof(type)); - return type.GetTypeInfo().ImplementedInterfaces + + var result = type.GetTypeInfo().ImplementedInterfaces .Where(GeneratorOptions.IsTypeNotBlacklisted); + + var baseType = type.GetTypeInfo().BaseType; + if (IsNotNullAndNotObjectAndNotBlacklisted(baseType) && IsTsInterface(baseType)) + result = result.Concat(new[] { baseType }); + + return result; } + + private bool IsNullOrObjectOrBlacklisted(Type type) => + type == null + || type == typeof(object) + || GeneratorOptions.IsTypeBlacklisted(type); + + private bool IsNotNullAndNotObjectAndNotBlacklisted(Type type) => + !IsNullOrObjectOrBlacklisted(type); } } diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs index 8ed39abc..f06c99bb 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs +++ b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs @@ -6,7 +6,6 @@ using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; using TypeGen.IntegrationTest.Blacklist.Entities; -using TypeGen.IntegrationTest.CircularGenericConstraint.TestClasses; using TypeGen.IntegrationTest.TestingUtils; using Xunit; diff --git a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/CircularGenericConstraintTest.cs b/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/CircularGenericConstraintTest.cs index fbc95a28..b2c6f119 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/CircularGenericConstraintTest.cs +++ b/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/CircularGenericConstraintTest.cs @@ -1,6 +1,6 @@ using System; using System.Threading.Tasks; -using TypeGen.IntegrationTest.CircularGenericConstraint.TestClasses; +using TypeGen.IntegrationTest.CircularGenericConstraint.Entities; using TypeGen.IntegrationTest.CommonCases; using TypeGen.IntegrationTest.TestingUtils; using Xunit; diff --git a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/TestClasses/TestClasses.cs b/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Entities/TestClasses.cs similarity index 94% rename from src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/TestClasses/TestClasses.cs rename to src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Entities/TestClasses.cs index 9c1281cc..d6469983 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/TestClasses/TestClasses.cs +++ b/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Entities/TestClasses.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CircularGenericConstraint.TestClasses +namespace TypeGen.IntegrationTest.CircularGenericConstraint.Entities { [ExportTsClass] public class RecursiveConstraintClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/DefaultExportTest.cs b/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/DefaultExportTest.cs index 283a4217..15cd7f05 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/DefaultExportTest.cs +++ b/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/DefaultExportTest.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Tasks; -using TypeGen.IntegrationTest.CircularGenericConstraint.TestClasses; using TypeGen.IntegrationTest.CommonCases; using TypeGen.IntegrationTest.DefaultExport.Entities; using TypeGen.IntegrationTest.TestingUtils; diff --git a/src/TypeGen/TypeGen.IntegrationTest/Extensions/StringExtensions.cs b/src/TypeGen/TypeGen.IntegrationTest/Extensions/StringExtensions.cs index 624ca8bd..5b9f5529 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Extensions/StringExtensions.cs +++ b/src/TypeGen/TypeGen.IntegrationTest/Extensions/StringExtensions.cs @@ -2,8 +2,9 @@ namespace TypeGen.IntegrationTest.Extensions; public static class StringExtensions { - public static string FormatOutput(this string output) - => output + public static string NormalizeFileContent(this string content) + => content + .Trim('\uFEFF', '\u200B') .Trim() .Replace("\n", "") .Replace("\r", "") diff --git a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/EmbededResourceReader.cs b/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/EmbededResourceReader.cs index ea6a6507..bff8703a 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/EmbededResourceReader.cs +++ b/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/EmbededResourceReader.cs @@ -3,6 +3,7 @@ using System.Text; using System.Threading.Tasks; using TypeGen.Core; +using System; namespace TypeGen.IntegrationTest.TestingUtils { @@ -10,22 +11,14 @@ public static class EmbededResourceReader { public static async Task GetEmbeddedResourceAsync(string name) { - using (Stream stream = typeof(EmbededResourceReader).GetTypeInfo().Assembly.GetManifestResourceStream(name)) - { - if (stream == null) - { - throw new CoreException($"Could not find embedded resource '{name}'"); - } + await using var stream = typeof(EmbededResourceReader).GetTypeInfo().Assembly.GetManifestResourceStream(name); + + if (stream == null) + throw new CoreException($"Could not find embedded resource '{name}'"); - var contentBytes = new byte[stream.Length]; - await stream.ReadAsync(contentBytes, 0, (int)stream.Length); - var res = Encoding.UTF8.GetString(contentBytes); - return res - .Trim('\uFEFF') - .Replace("\n", "") - .Replace("\r", "") - .Replace("\r\n", ""); - } + var contentBytes = new byte[stream.Length]; + await stream.ReadAsync(contentBytes.AsMemory(0, (int)stream.Length)); + return Encoding.UTF8.GetString(contentBytes); } } } diff --git a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs b/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs index 42d16365..c1480b38 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs +++ b/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs @@ -18,10 +18,10 @@ protected async Task TestFromAssembly(Type type, string expectedLocation) var interceptor = GeneratorOutputInterceptor.CreateInterceptor(generator); await generator.GenerateAsync(type.Assembly); - var expected = (await readExpectedTask).Trim(); + var expected = (await readExpectedTask).NormalizeFileContent(); interceptor.GeneratedOutputs.Should().ContainKey(type); - interceptor.GeneratedOutputs[type].Content.FormatOutput().Should().Be(expected); + interceptor.GeneratedOutputs[type].Content.NormalizeFileContent().Should().Be(expected); } protected static async Task TestGenerationSpec(Type type, string expectedLocation, @@ -32,9 +32,9 @@ protected static async Task TestGenerationSpec(Type type, string expectedLocatio var interceptor = GeneratorOutputInterceptor.CreateInterceptor(generator); await generator.GenerateAsync(new[] { generationSpec }); - var expected = (await readExpectedTask).Trim(); + var expected = (await readExpectedTask).NormalizeFileContent(); interceptor.GeneratedOutputs.Should().ContainKey(type); - interceptor.GeneratedOutputs[type].Content.FormatOutput().Should().Be(expected); + interceptor.GeneratedOutputs[type].Content.NormalizeFileContent().Should().Be(expected); } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsClass.cs b/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsClass.cs new file mode 100644 index 00000000..b21e9476 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsClass.cs @@ -0,0 +1,5 @@ +namespace TypeGen.IntegrationTest.TsClassExtendsTsInterface.Entities; + +public class TsClass : TsInterface +{ +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsInterface.cs b/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsInterface.cs new file mode 100644 index 00000000..6ce09853 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsInterface.cs @@ -0,0 +1,6 @@ +namespace TypeGen.IntegrationTest.TsClassExtendsTsInterface.Entities; + +public class TsInterface +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Expected/ts-class.ts b/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Expected/ts-class.ts new file mode 100644 index 00000000..97505a6c --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Expected/ts-class.ts @@ -0,0 +1,9 @@ +/** + * This is a TypeGen auto-generated file. + * Any changes made to this file can be lost when this file is regenerated. + */ + +import { TsInterface } from "./ts-interface"; + +export class TsClass implements TsInterface { +} diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs b/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs new file mode 100644 index 00000000..caaa4394 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; +using TypeGen.Core.Generator; +using TypeGen.Core.SpecGeneration; +using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.IntegrationTest.TsClassExtendsTsInterface.Entities; +using Xunit; + +namespace TypeGen.IntegrationTest.TsClassExtendsTsInterface; + +public class TsClassExtendsTsInterfaceTest : GenerationTestBase +{ + [Fact] + public async Task TsClassExtendsTsInterface_Test() + { + var type = typeof(TsClass); + const string expectedLocation = "TypeGen.IntegrationTest.TsClassExtendsTsInterface.Expected.ts-class.ts"; + var generationSpec = new TsClassExtendsTsInterfaceGenerationSpec(); + var generatorOptions = new GeneratorOptions(); + + await TestGenerationSpec(type, expectedLocation, generationSpec, generatorOptions); + } + + private class TsClassExtendsTsInterfaceGenerationSpec : GenerationSpec + { + public TsClassExtendsTsInterfaceGenerationSpec() + { + AddClass(); + AddInterface(); + } + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj b/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj index 02b25074..f8d272ee 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj +++ b/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj @@ -112,6 +112,7 @@ + From fd8e17438e739da73d7ebf6a6edc242c507f4bb8 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Sat, 26 Aug 2023 01:32:09 +0200 Subject: [PATCH 10/16] version update to 4.5.0 --- nuget-dotnetcli/dotnet-typegen.nuspec | 6 ++++-- nuget/TypeGen.nuspec | 6 ++++-- src/TypeGen/TypeGen.Cli/AppConfig.cs | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/nuget-dotnetcli/dotnet-typegen.nuspec b/nuget-dotnetcli/dotnet-typegen.nuspec index 2e11b146..b11faf93 100644 --- a/nuget-dotnetcli/dotnet-typegen.nuspec +++ b/nuget-dotnetcli/dotnet-typegen.nuspec @@ -2,7 +2,7 @@ dotnet-typegen - 4.4.1 + 4.5.0 Jacek Burzynski Jacek Burzynski LICENSE @@ -11,7 +11,9 @@ false TypeGen .NET Core CLI tool (TypeGen is a single-class-per-file C# to TypeScript generator) -- fixed exportTypesAsInterfacesByDefault and useImportType not working in tgconfig.json +- added the ability to blacklist/whitelist individual types (this also fixes records not generating correctly #164) +- TS class : TS interface inheritance is now possible - in this case TS class implements TS interface +- added the ability to specify custom header and body as an attribute or spec #166 #167 code-generator generator code typescript ts csharp cs dotnet cli diff --git a/nuget/TypeGen.nuspec b/nuget/TypeGen.nuspec index 00f0935c..f95110de 100644 --- a/nuget/TypeGen.nuspec +++ b/nuget/TypeGen.nuspec @@ -2,7 +2,7 @@ TypeGen - 4.4.1 + 4.5.0 Jacek Burzynski Jacek Burzynski LICENSE @@ -11,7 +11,9 @@ false TypeGen is a single-class-per-file C# to TypeScript generator -- fixed exportTypesAsInterfacesByDefault and useImportType not working in tgconfig.json +- added the ability to blacklist/whitelist individual types (this also fixes records not generating correctly #164) +- TS class : TS interface inheritance is now possible - in this case TS class implements TS interface +- added the ability to specify custom header and body as an attribute or spec #166 #167 code-generator generator code typescript ts csharp cs diff --git a/src/TypeGen/TypeGen.Cli/AppConfig.cs b/src/TypeGen/TypeGen.Cli/AppConfig.cs index a67eb3c6..2f8bf5f5 100644 --- a/src/TypeGen/TypeGen.Cli/AppConfig.cs +++ b/src/TypeGen/TypeGen.Cli/AppConfig.cs @@ -8,6 +8,6 @@ namespace TypeGen.Cli { internal class AppConfig { - public static string Version => "4.4.1"; + public static string Version => "4.5.0"; } } From 5eec020cac6f8187df5ce4776acb37c6d5c1377e Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Sat, 26 Aug 2023 02:49:23 +0200 Subject: [PATCH 11/16] changed file structure in TypeGen.Cli --- .../Business/GeneratorOptionsProviderTest.cs | 3 +- .../TypeGen.Cli.Test/Models/TgConfigTest.cs | 2 +- .../{AppConfig.cs => ApplicationConfig.cs} | 2 +- src/TypeGen/TypeGen.Cli/AssemblyInfo.cs | 3 +- .../ProjectBuild.cs} | 10 ++--- src/TypeGen/TypeGen.Cli/Program.cs | 17 +++++---- .../IProjectFileManager.cs | 2 +- .../ProjectFileManager.cs | 11 +----- src/TypeGen/TypeGen.Cli/TypeGen.Cli.csproj | 5 ++- .../ConfigProvider.cs | 10 ++--- .../GeneratorOptionsProvider.cs | 13 ++----- .../IConfigProvider.cs | 4 +- .../IGeneratorOptionsProvider.cs | 4 +- .../{Models => TypeGenConfig}/TgConfig.cs | 5 +-- .../AssemblyResolver.cs | 4 +- .../IAssemblyResolver.cs | 2 +- .../ITypeResolver.cs | 2 +- .../TypeResolver.cs | 3 +- src/TypeGen/TypeGen.Core/AssemblyInfo.cs | 5 ++- .../{ => Shims}/IsExternalInit.cs | 0 src/TypeGen/TypeGen.Core/TypeGen.Core.csproj | 4 +- .../ReflectionToCsModelConverter.cs | 7 ++-- .../TypeGen.Core/TypeModel/Csharp/CsEnum.cs | 8 ++-- .../TypeModel/Csharp/CsEnumValue.cs | 6 +-- .../TypeGen.Core/TypeModel/Csharp/CsField.cs | 8 ++-- .../TypeGen.Core/TypeModel/Csharp/CsGpType.cs | 38 +++++++++---------- .../TypeModel/Csharp/CsPrimitive.cs | 4 +- .../TypeModel/Csharp/CsProperty.cs | 8 ++-- .../TypeGen.Core/TypeModel/Csharp/CsType.cs | 6 +-- .../TypeModel/TypeScript/TsClass.cs | 10 ++--- .../TypeModel/TypeScript/TsEnum.cs | 4 +- .../TypeModel/TypeScript/TsInterface.cs | 8 ++-- .../TypeModel/TypeScript/TsType.cs | 4 +- update-version.ps1 | 30 ++++++++++----- 34 files changed, 123 insertions(+), 129 deletions(-) rename src/TypeGen/TypeGen.Cli/{AppConfig.cs => ApplicationConfig.cs} (84%) rename src/TypeGen/TypeGen.Cli/{Business/ProjectBuilder.cs => Build/ProjectBuild.cs} (85%) rename src/TypeGen/TypeGen.Cli/{Business => ProjectFileManagement}/IProjectFileManager.cs (89%) rename src/TypeGen/TypeGen.Cli/{Business => ProjectFileManagement}/ProjectFileManager.cs (93%) rename src/TypeGen/TypeGen.Cli/{Business => TypeGenConfig}/ConfigProvider.cs (96%) rename src/TypeGen/TypeGen.Cli/{Business => TypeGenConfig}/GeneratorOptionsProvider.cs (94%) rename src/TypeGen/TypeGen.Cli/{Business => TypeGenConfig}/IConfigProvider.cs (85%) rename src/TypeGen/TypeGen.Cli/{Business => TypeGenConfig}/IGeneratorOptionsProvider.cs (88%) rename src/TypeGen/TypeGen.Cli/{Models => TypeGenConfig}/TgConfig.cs (98%) rename src/TypeGen/TypeGen.Cli/{Business => TypeResolution}/AssemblyResolver.cs (98%) rename src/TypeGen/TypeGen.Cli/{Business => TypeResolution}/IAssemblyResolver.cs (84%) rename src/TypeGen/TypeGen.Cli/{Business => TypeResolution}/ITypeResolver.cs (86%) rename src/TypeGen/TypeGen.Cli/{Business => TypeResolution}/TypeResolver.cs (98%) rename src/TypeGen/TypeGen.Core/{ => Shims}/IsExternalInit.cs (100%) diff --git a/src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs b/src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs index c8eda99b..5810741c 100644 --- a/src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs +++ b/src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs @@ -5,7 +5,8 @@ using FluentAssertions; using NSubstitute; using TypeGen.Cli.Business; -using TypeGen.Cli.Models; +using TypeGen.Cli.TypeGenConfig; +using TypeGen.Cli.TypeResolution; using TypeGen.Core.Generator; using Xunit; diff --git a/src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs b/src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs index f1156c9f..d7364ae8 100644 --- a/src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs +++ b/src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs @@ -1,9 +1,9 @@ using System.Linq; using FluentAssertions; -using TypeGen.Cli.Models; using TypeGen.Core; using Xunit; using TypeGen.Cli.Extensions; +using TypeGen.Cli.TypeGenConfig; using TypeGen.Core.Extensions; namespace TypeGen.Cli.Test.Models diff --git a/src/TypeGen/TypeGen.Cli/AppConfig.cs b/src/TypeGen/TypeGen.Cli/ApplicationConfig.cs similarity index 84% rename from src/TypeGen/TypeGen.Cli/AppConfig.cs rename to src/TypeGen/TypeGen.Cli/ApplicationConfig.cs index 2f8bf5f5..591dc110 100644 --- a/src/TypeGen/TypeGen.Cli/AppConfig.cs +++ b/src/TypeGen/TypeGen.Cli/ApplicationConfig.cs @@ -6,7 +6,7 @@ namespace TypeGen.Cli { - internal class AppConfig + internal class ApplicationConfig { public static string Version => "4.5.0"; } diff --git a/src/TypeGen/TypeGen.Cli/AssemblyInfo.cs b/src/TypeGen/TypeGen.Cli/AssemblyInfo.cs index 30994595..1c6e4a4b 100644 --- a/src/TypeGen/TypeGen.Cli/AssemblyInfo.cs +++ b/src/TypeGen/TypeGen.Cli/AssemblyInfo.cs @@ -1,4 +1,5 @@ -using System.Runtime.CompilerServices; +using System.Reflection; +using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("TypeGen.IntegrationTest")] [assembly: InternalsVisibleTo("TypeGen.Cli.Test")] diff --git a/src/TypeGen/TypeGen.Cli/Business/ProjectBuilder.cs b/src/TypeGen/TypeGen.Cli/Build/ProjectBuild.cs similarity index 85% rename from src/TypeGen/TypeGen.Cli/Business/ProjectBuilder.cs rename to src/TypeGen/TypeGen.Cli/Build/ProjectBuild.cs index 9e15db8c..74315f39 100644 --- a/src/TypeGen/TypeGen.Cli/Business/ProjectBuilder.cs +++ b/src/TypeGen/TypeGen.Cli/Build/ProjectBuild.cs @@ -1,18 +1,14 @@ using System; -using System.Collections.Generic; using System.Diagnostics; -using System.IO; -using System.Linq; using TypeGen.Core.Logging; -using TypeGen.Core.Storage; -namespace TypeGen.Cli.Business +namespace TypeGen.Cli.Build { - internal class ProjectBuilder + internal class ProjectBuild { private readonly ILogger _logger; - public ProjectBuilder(ILogger logger) + public ProjectBuild(ILogger logger) { _logger = logger; } diff --git a/src/TypeGen/TypeGen.Cli/Program.cs b/src/TypeGen/TypeGen.Cli/Program.cs index e1d4b121..81e1bf6d 100644 --- a/src/TypeGen/TypeGen.Cli/Program.cs +++ b/src/TypeGen/TypeGen.Cli/Program.cs @@ -4,16 +4,19 @@ using System.Linq; using System.Reflection; using System.Xml; +using TypeGen.Cli.Build; using TypeGen.Cli.Business; -using TypeGen.Cli.Models; +using TypeGen.Cli.ProjectFileManagement; +using TypeGen.Cli.TypeGenConfig; +using TypeGen.Cli.TypeResolution; using TypeGen.Core; using TypeGen.Core.Extensions; using TypeGen.Core.Generator; using TypeGen.Core.Logging; using TypeGen.Core.SpecGeneration; using TypeGen.Core.Storage; -using IGeneratorOptionsProvider = TypeGen.Cli.Business.IGeneratorOptionsProvider; -using GeneratorOptionsProvider = TypeGen.Cli.Business.GeneratorOptionsProvider; +using IGeneratorOptionsProvider = TypeGen.Cli.TypeGenConfig.IGeneratorOptionsProvider; +using GeneratorOptionsProvider = TypeGen.Cli.TypeGenConfig.GeneratorOptionsProvider; namespace TypeGen.Cli { @@ -24,7 +27,7 @@ internal class Program private static IConfigProvider _configProvider; private static IGeneratorOptionsProvider _generatorOptionsProvider; private static IProjectFileManager _projectFileManager; - private static ProjectBuilder _projectBuilder; + private static ProjectBuild _projectBuild; private static IAssemblyResolver _assemblyResolver; private static void InitializeServices(string[] args) @@ -35,7 +38,7 @@ private static void InitializeServices(string[] args) _fileSystem = new FileSystem(); _configProvider = new ConfigProvider(_fileSystem, _logger); _projectFileManager = new ProjectFileManager(_fileSystem); - _projectBuilder = new ProjectBuilder(_logger); + _projectBuild = new ProjectBuild(_logger); } private static int Main(string[] args) @@ -129,7 +132,7 @@ private static void Generate(string projectFolder, string configPath, string? ou // generate if (config.ClearOutputDirectory == true) _fileSystem.ClearDirectory(generatorOptions.BaseOutputDirectory); - if (config.BuildProject == true) _projectBuilder.Build(projectFolder); + if (config.BuildProject == true) _projectBuild.Build(projectFolder); _logger.Log($"Generating files for project \"{projectFolder}\"...", LogLevel.Info); @@ -187,7 +190,7 @@ private static IEnumerable GetAssemblies(IEnumerable assemblyN private static void ShowHelp() { - Console.WriteLine($"TypeGen v{AppConfig.Version}" + Environment.NewLine + + Console.WriteLine($"TypeGen v{ApplicationConfig.Version}" + Environment.NewLine + Environment.NewLine + "Usage: [dotnet-]typegen [options] [command]" + Environment.NewLine + Environment.NewLine + diff --git a/src/TypeGen/TypeGen.Cli/Business/IProjectFileManager.cs b/src/TypeGen/TypeGen.Cli/ProjectFileManagement/IProjectFileManager.cs similarity index 89% rename from src/TypeGen/TypeGen.Cli/Business/IProjectFileManager.cs rename to src/TypeGen/TypeGen.Cli/ProjectFileManagement/IProjectFileManager.cs index a3dee5a7..18e95ddc 100644 --- a/src/TypeGen/TypeGen.Cli/Business/IProjectFileManager.cs +++ b/src/TypeGen/TypeGen.Cli/ProjectFileManagement/IProjectFileManager.cs @@ -1,6 +1,6 @@ using System.Xml; -namespace TypeGen.Cli.Business +namespace TypeGen.Cli.ProjectFileManagement { internal interface IProjectFileManager { diff --git a/src/TypeGen/TypeGen.Cli/Business/ProjectFileManager.cs b/src/TypeGen/TypeGen.Cli/ProjectFileManagement/ProjectFileManager.cs similarity index 93% rename from src/TypeGen/TypeGen.Cli/Business/ProjectFileManager.cs rename to src/TypeGen/TypeGen.Cli/ProjectFileManagement/ProjectFileManager.cs index 5aaff973..8aefd9af 100644 --- a/src/TypeGen/TypeGen.Cli/Business/ProjectFileManager.cs +++ b/src/TypeGen/TypeGen.Cli/ProjectFileManagement/ProjectFileManager.cs @@ -1,16 +1,9 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Linq; using System.Xml; -using TypeGen.Core.Utils; -using TypeGen.Core.Extensions; using TypeGen.Core.Storage; using TypeGen.Core.Validation; -namespace TypeGen.Cli.Business +namespace TypeGen.Cli.ProjectFileManagement { /// /// For ASP.NET (.NET Framework) versions (addFilesToProject parameter in TypeGen CLI) diff --git a/src/TypeGen/TypeGen.Cli/TypeGen.Cli.csproj b/src/TypeGen/TypeGen.Cli/TypeGen.Cli.csproj index 5e7f83dc..aae7cacf 100644 --- a/src/TypeGen/TypeGen.Cli/TypeGen.Cli.csproj +++ b/src/TypeGen/TypeGen.Cli/TypeGen.Cli.csproj @@ -1,11 +1,14 @@ - + Exe net7.0 + 4.5.0.0 + 4.5.0.0 + diff --git a/src/TypeGen/TypeGen.Cli/Business/ConfigProvider.cs b/src/TypeGen/TypeGen.Cli/TypeGenConfig/ConfigProvider.cs similarity index 96% rename from src/TypeGen/TypeGen.Cli/Business/ConfigProvider.cs rename to src/TypeGen/TypeGen.Cli/TypeGenConfig/ConfigProvider.cs index c711032d..e02d37ab 100644 --- a/src/TypeGen/TypeGen.Cli/Business/ConfigProvider.cs +++ b/src/TypeGen/TypeGen.Cli/TypeGenConfig/ConfigProvider.cs @@ -1,17 +1,13 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; using Newtonsoft.Json; -using TypeGen.Cli.Models; +using TypeGen.Cli.Business; using TypeGen.Core.Logging; -using TypeGen.Core.Utils; using TypeGen.Core.Storage; using TypeGen.Core.Validation; -namespace TypeGen.Cli.Business +namespace TypeGen.Cli.TypeGenConfig { internal class ConfigProvider : IConfigProvider { diff --git a/src/TypeGen/TypeGen.Cli/Business/GeneratorOptionsProvider.cs b/src/TypeGen/TypeGen.Cli/TypeGenConfig/GeneratorOptionsProvider.cs similarity index 94% rename from src/TypeGen/TypeGen.Cli/Business/GeneratorOptionsProvider.cs rename to src/TypeGen/TypeGen.Cli/TypeGenConfig/GeneratorOptionsProvider.cs index 6d0a92aa..a351d5ff 100644 --- a/src/TypeGen/TypeGen.Cli/Business/GeneratorOptionsProvider.cs +++ b/src/TypeGen/TypeGen.Cli/TypeGenConfig/GeneratorOptionsProvider.cs @@ -1,22 +1,15 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; +using TypeGen.Cli.Business; using TypeGen.Cli.Extensions; -using TypeGen.Cli.Models; -using TypeGen.Core; +using TypeGen.Cli.TypeResolution; using TypeGen.Core.Converters; -using TypeGen.Core.Extensions; using TypeGen.Core.Generator; -using TypeGen.Core.Generator.Services; -using TypeGen.Core.Logging; -using TypeGen.Core.Storage; using TypeGen.Core.Validation; -namespace TypeGen.Cli.Business +namespace TypeGen.Cli.TypeGenConfig { internal class GeneratorOptionsProvider : IGeneratorOptionsProvider { diff --git a/src/TypeGen/TypeGen.Cli/Business/IConfigProvider.cs b/src/TypeGen/TypeGen.Cli/TypeGenConfig/IConfigProvider.cs similarity index 85% rename from src/TypeGen/TypeGen.Cli/Business/IConfigProvider.cs rename to src/TypeGen/TypeGen.Cli/TypeGenConfig/IConfigProvider.cs index 06bec0c2..c97a25f8 100644 --- a/src/TypeGen/TypeGen.Cli/Business/IConfigProvider.cs +++ b/src/TypeGen/TypeGen.Cli/TypeGenConfig/IConfigProvider.cs @@ -1,6 +1,4 @@ -using TypeGen.Cli.Models; - -namespace TypeGen.Cli.Business +namespace TypeGen.Cli.TypeGenConfig { internal interface IConfigProvider { diff --git a/src/TypeGen/TypeGen.Cli/Business/IGeneratorOptionsProvider.cs b/src/TypeGen/TypeGen.Cli/TypeGenConfig/IGeneratorOptionsProvider.cs similarity index 88% rename from src/TypeGen/TypeGen.Cli/Business/IGeneratorOptionsProvider.cs rename to src/TypeGen/TypeGen.Cli/TypeGenConfig/IGeneratorOptionsProvider.cs index b32cbcc4..dbfc6ad8 100644 --- a/src/TypeGen/TypeGen.Cli/Business/IGeneratorOptionsProvider.cs +++ b/src/TypeGen/TypeGen.Cli/TypeGenConfig/IGeneratorOptionsProvider.cs @@ -1,10 +1,8 @@ using System.Collections.Generic; using System.Reflection; -using TypeGen.Cli.Models; -using TypeGen.Core; using TypeGen.Core.Generator; -namespace TypeGen.Cli.Business +namespace TypeGen.Cli.TypeGenConfig { internal interface IGeneratorOptionsProvider { diff --git a/src/TypeGen/TypeGen.Cli/Models/TgConfig.cs b/src/TypeGen/TypeGen.Cli/TypeGenConfig/TgConfig.cs similarity index 98% rename from src/TypeGen/TypeGen.Cli/Models/TgConfig.cs rename to src/TypeGen/TypeGen.Cli/TypeGenConfig/TgConfig.cs index 67799ab1..f1f562b1 100644 --- a/src/TypeGen/TypeGen.Cli/Models/TgConfig.cs +++ b/src/TypeGen/TypeGen.Cli/TypeGenConfig/TgConfig.cs @@ -1,14 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.Serialization; using TypeGen.Cli.Extensions; -using TypeGen.Core; -using TypeGen.Core.Converters; using TypeGen.Core.Extensions; using TypeGen.Core.Generator; -namespace TypeGen.Cli.Models +namespace TypeGen.Cli.TypeGenConfig { /// /// Represents console configuration diff --git a/src/TypeGen/TypeGen.Cli/Business/AssemblyResolver.cs b/src/TypeGen/TypeGen.Cli/TypeResolution/AssemblyResolver.cs similarity index 98% rename from src/TypeGen/TypeGen.Cli/Business/AssemblyResolver.cs rename to src/TypeGen/TypeGen.Cli/TypeResolution/AssemblyResolver.cs index 19105ed9..ccae33bc 100644 --- a/src/TypeGen/TypeGen.Cli/Business/AssemblyResolver.cs +++ b/src/TypeGen/TypeGen.Cli/TypeResolution/AssemblyResolver.cs @@ -9,7 +9,7 @@ using TypeGen.Core.Logging; using TypeGen.Core.Storage; -namespace TypeGen.Cli.Business +namespace TypeGen.Cli.TypeResolution { internal class AssemblyResolver : IAssemblyResolver { @@ -21,7 +21,7 @@ internal class AssemblyResolver : IAssemblyResolver public IEnumerable Directories { get => _directories; - set => _directories = value?.Select(d => Path.IsPathRooted(d) ? d : Path.Combine(_projectFolder, d)); + set => _directories = value?.Select(d => Path.IsPathRooted((string)d) ? d : Path.Combine(_projectFolder, d)); } private readonly string _globalFallbackPath; diff --git a/src/TypeGen/TypeGen.Cli/Business/IAssemblyResolver.cs b/src/TypeGen/TypeGen.Cli/TypeResolution/IAssemblyResolver.cs similarity index 84% rename from src/TypeGen/TypeGen.Cli/Business/IAssemblyResolver.cs rename to src/TypeGen/TypeGen.Cli/TypeResolution/IAssemblyResolver.cs index 950c19e3..abde2508 100644 --- a/src/TypeGen/TypeGen.Cli/Business/IAssemblyResolver.cs +++ b/src/TypeGen/TypeGen.Cli/TypeResolution/IAssemblyResolver.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace TypeGen.Cli.Business +namespace TypeGen.Cli.TypeResolution { internal interface IAssemblyResolver { diff --git a/src/TypeGen/TypeGen.Cli/Business/ITypeResolver.cs b/src/TypeGen/TypeGen.Cli/TypeResolution/ITypeResolver.cs similarity index 86% rename from src/TypeGen/TypeGen.Cli/Business/ITypeResolver.cs rename to src/TypeGen/TypeGen.Cli/TypeResolution/ITypeResolver.cs index e8dfaf67..7baf6e0b 100644 --- a/src/TypeGen/TypeGen.Cli/Business/ITypeResolver.cs +++ b/src/TypeGen/TypeGen.Cli/TypeResolution/ITypeResolver.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace TypeGen.Cli.Business; +namespace TypeGen.Cli.TypeResolution; internal interface ITypeResolver { diff --git a/src/TypeGen/TypeGen.Cli/Business/TypeResolver.cs b/src/TypeGen/TypeGen.Cli/TypeResolution/TypeResolver.cs similarity index 98% rename from src/TypeGen/TypeGen.Cli/Business/TypeResolver.cs rename to src/TypeGen/TypeGen.Cli/TypeResolution/TypeResolver.cs index b72559fd..90d849e8 100644 --- a/src/TypeGen/TypeGen.Cli/Business/TypeResolver.cs +++ b/src/TypeGen/TypeGen.Cli/TypeResolution/TypeResolver.cs @@ -3,13 +3,12 @@ using System.IO; using System.Linq; using System.Reflection; -using TypeGen.Core; using TypeGen.Core.Extensions; using TypeGen.Core.Generator; using TypeGen.Core.Logging; using TypeGen.Core.Storage; -namespace TypeGen.Cli.Business +namespace TypeGen.Cli.TypeResolution { internal class TypeResolver : ITypeResolver { diff --git a/src/TypeGen/TypeGen.Core/AssemblyInfo.cs b/src/TypeGen/TypeGen.Core/AssemblyInfo.cs index 99437e4c..4c9e01aa 100644 --- a/src/TypeGen/TypeGen.Core/AssemblyInfo.cs +++ b/src/TypeGen/TypeGen.Core/AssemblyInfo.cs @@ -1,7 +1,8 @@ -using System.Runtime.CompilerServices; +using System.Reflection; +using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("TypeGen.Cli")] [assembly: InternalsVisibleTo("TypeGen.IntegrationTest")] [assembly: InternalsVisibleTo("TypeGen.Cli.Test")] [assembly: InternalsVisibleTo("TypeGen.Core.Test")] -[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/IsExternalInit.cs b/src/TypeGen/TypeGen.Core/Shims/IsExternalInit.cs similarity index 100% rename from src/TypeGen/TypeGen.Core/IsExternalInit.cs rename to src/TypeGen/TypeGen.Core/Shims/IsExternalInit.cs diff --git a/src/TypeGen/TypeGen.Core/TypeGen.Core.csproj b/src/TypeGen/TypeGen.Core/TypeGen.Core.csproj index be93202d..57345189 100644 --- a/src/TypeGen/TypeGen.Core/TypeGen.Core.csproj +++ b/src/TypeGen/TypeGen.Core/TypeGen.Core.csproj @@ -1,8 +1,10 @@ - + netstandard2.0;net7.0 TypeGen.Core.xml latest + 4.5.0.0 + 4.5.0.0 diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs b/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs index 9b0dc189..cb9189dd 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Conversion/ReflectionToCsModelConverter.cs @@ -15,10 +15,9 @@ public static CsType ConvertType(Type type) { Requires.NotNull(type, nameof(type)); - if (type.IsNullable()) - return ConvertTypePrivate(Nullable.GetUnderlyingType(type)!, true); - else - return ConvertTypePrivate(type, false); + return type.IsNullable() + ? ConvertTypePrivate(Nullable.GetUnderlyingType(type)!, true) + : ConvertTypePrivate(type, false); } private static CsType ConvertTypePrivate(Type type, bool isNullable) diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs index afb7f227..8f60e5b2 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnum.cs @@ -5,6 +5,10 @@ namespace TypeGen.Core.TypeModel.Csharp; internal class CsEnum : CsType { + public string FullName { get; } + public IReadOnlyCollection TgAttributes { get; } + public IReadOnlyCollection Values { get; } + public CsEnum(string fullName, string name, IReadOnlyCollection tgAttributes, @@ -17,7 +21,5 @@ public CsEnum(string fullName, TgAttributes = tgAttributes; } - public string FullName { get; } - public IReadOnlyCollection TgAttributes { get; } - public IReadOnlyCollection Values { get; } + } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnumValue.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnumValue.cs index ad318a36..872ca696 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnumValue.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsEnumValue.cs @@ -2,12 +2,12 @@ namespace TypeGen.Core.TypeModel.Csharp; internal class CsEnumValue { + public string Name { get; } + public object UnderlyingValue { get; } + public CsEnumValue(string name, object underlyingValue) { Name = name; UnderlyingValue = underlyingValue; } - - public string Name { get; } - public object UnderlyingValue { get; } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs index 81bade92..a44cb233 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsField.cs @@ -2,14 +2,14 @@ namespace TypeGen.Core.TypeModel.Csharp; internal class CsField { + public CsType Type { get; } + public string Name { get; } + public object DefaultValue { get; } + public CsField(CsType type, string name, object defaultValue) { Type = type; Name = name; DefaultValue = defaultValue; } - - public CsType Type { get; } - public string Name { get; } - public object DefaultValue { get; } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs index 57903125..bd5351a2 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsGpType.cs @@ -12,6 +12,25 @@ namespace TypeGen.Core.TypeModel.Csharp; /// internal class CsGpType : CsType { + public string FullName { get; init; } + public IReadOnlyCollection GenericTypes { get; init; } + public CsGpType? Base { get; init; } + public IReadOnlyCollection ImplementedInterfaces { get; init; } + public IReadOnlyCollection Fields { get; init; } + public IReadOnlyCollection Properties { get; init; } + public IReadOnlyCollection TgAttributes { get; init; } + + public bool IsNonDictionaryEnumerable => + FullName != typeof(string).FullName + && !IsDictionary + && (ImplementsInterface(typeof(IEnumerable).FullName!) || FullName.StartsWith(typeof(IEnumerable).FullName!)); + + public bool IsDictionary => + ImplementsInterface(typeof(IDictionary<,>).FullName!) + || FullName.StartsWith(typeof(IDictionary<,>).FullName!) + || ImplementsInterface(typeof(IDictionary).FullName!) + || FullName.StartsWith(typeof(IDictionary).FullName!); + private CsGpType(string name, bool isNullable) : base(name, isNullable) { @@ -75,24 +94,5 @@ public static CsGpType Struct(string fullName, }; } - public string FullName { get; init; } - public IReadOnlyCollection GenericTypes { get; init; } - public CsGpType? Base { get; init; } - public IReadOnlyCollection ImplementedInterfaces { get; init; } - public IReadOnlyCollection Fields { get; init; } - public IReadOnlyCollection Properties { get; init; } - public IReadOnlyCollection TgAttributes { get; init; } - - public bool IsNonDictionaryEnumerable => - FullName != typeof(string).FullName - && !IsDictionary - && (ImplementsInterface(typeof(IEnumerable).FullName!) || FullName.StartsWith(typeof(IEnumerable).FullName!)); - - public bool IsDictionary => - ImplementsInterface(typeof(IDictionary<,>).FullName!) - || FullName.StartsWith(typeof(IDictionary<,>).FullName!) - || ImplementsInterface(typeof(IDictionary).FullName!) - || FullName.StartsWith(typeof(IDictionary).FullName!); - private bool ImplementsInterface(string fullName) => ImplementedInterfaces.Contains(x => x.FullName == fullName); } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsPrimitive.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsPrimitive.cs index 37751fc5..602460da 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsPrimitive.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsPrimitive.cs @@ -2,11 +2,11 @@ namespace TypeGen.Core.TypeModel.Csharp; internal class CsPrimitive : CsType { + public string FullName { get; } + public CsPrimitive(string fullName, string name, bool isNullable) : base(name, isNullable) { FullName = fullName; } - - public string FullName { get; } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs index 26b88b54..a808a3d0 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsProperty.cs @@ -2,14 +2,14 @@ namespace TypeGen.Core.TypeModel.Csharp; internal class CsProperty { + public CsType Type { get; } + public string Name { get; } + public object DefaultValue { get; } + public CsProperty(CsType type, string name, object defaultValue) { Type = type; Name = name; DefaultValue = defaultValue; } - - public CsType Type { get; } - public string Name { get; } - public object DefaultValue { get; } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs index 883f6940..9333cc96 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/Csharp/CsType.cs @@ -5,12 +5,12 @@ namespace TypeGen.Core.TypeModel.Csharp; internal abstract class CsType { + public string Name { get; } + public bool IsNullable { get; } + protected CsType(string name, bool isNullable) { Name = name; IsNullable = isNullable; } - - public string Name { get; } - public bool IsNullable { get; } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsClass.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsClass.cs index ab690b52..84baaa5e 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsClass.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsClass.cs @@ -4,13 +4,13 @@ namespace TypeGen.Core.TypeModel.TypeScript; internal class TsClass : TsType { - public TsClass(string name, IReadOnlyCollection imports) - : base(name) - { - } - public IReadOnlyCollection Imports { get; } public string Base { get; } public IReadOnlyCollection ImplementedInterfaces { get; set; } public IReadOnlyCollection Properties { get; set; } + + public TsClass(string name, IReadOnlyCollection imports) + : base(name) + { + } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnum.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnum.cs index f3bb10e4..f109f808 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnum.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsEnum.cs @@ -4,9 +4,9 @@ namespace TypeGen.Core.TypeModel.TypeScript; internal class TsEnum : TsType { + public IReadOnlyCollection Values { get; } + public TsEnum(string name) : base(name) { } - - public IReadOnlyCollection Values { get; } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsInterface.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsInterface.cs index f763da20..d5962e36 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsInterface.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsInterface.cs @@ -4,11 +4,11 @@ namespace TypeGen.Core.TypeModel.TypeScript; internal class TsInterface : TsType { - public TsInterface(string name) : base(name) - { - } - public IReadOnlyCollection Imports { get; } public string Base { get; } public IReadOnlyCollection Properties { get; set; } + + public TsInterface(string name) : base(name) + { + } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsType.cs b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsType.cs index 5feae070..81cddcd4 100644 --- a/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsType.cs +++ b/src/TypeGen/TypeGen.Core/TypeModel/TypeScript/TsType.cs @@ -4,10 +4,10 @@ namespace TypeGen.Core.TypeModel.TypeScript; internal abstract class TsType { + public string Name { get; } + protected TsType(string name) { Name = name; } - - public string Name { get; } } \ No newline at end of file diff --git a/update-version.ps1 b/update-version.ps1 index dad496cd..1920c98b 100644 --- a/update-version.ps1 +++ b/update-version.ps1 @@ -1,25 +1,27 @@ if ($args.Length -eq 0) { Write-Host "examples: -./update-version increment # increments the minor version, i.e. the middle part of the version ./update-version 2.4.9 # changes the current version to 2.4.9" exit } $versionRegex = "^\d+\.\d+\.\d+$" +$newVersion = $args[0] -$oldVersion = (Select-Xml //version "nuget\TypeGen.nuspec")[0].Node.InnerText +if (-not ($newVersion -match $versionRegex)) { + Write-Host "Wrong version format. Should be: $($versionRegex)" + exit +} +$oldVersion = (Select-Xml //version "nuget\TypeGen.nuspec")[0].Node.InnerText $oldVersionMajor = $oldVersion.Split(".")[0] $oldVersionMinor = $oldVersion.Split(".")[1] -$newVersionMinor = ($oldVersionMinor -as [int]) + 1 -$newVersion = if ($args -contains "increment") {"$($oldVersionMajor).$($newVersionMinor).0"} else {$args[0]} +$newVersionMajor = $newVersion.Split(".")[0] +$newVersionMinor = $newVersion.Split(".")[1] -if (-not ($newVersion -match $versionRegex)) { - Write-Host "Wrong version format. Should be: $($versionRegex)" - exit -} +$assemblyOldVersion = "$($oldVersionMajor).$($oldVersionMinor).0.0" +$assemblyNewVersion = "$($newVersionMajor).$($newVersionMinor).0.0" # replace files' contents @@ -39,7 +41,7 @@ if (Test-Path $dotNetCliNuspecPath) { # (Get-Content $docsConfPath).Replace("version = u'$($oldVersion)'", "version = u'$($newVersion)'") | Set-Content $docsConfPath #} -$appConfigPath = "src\TypeGen\TypeGen.Cli\AppConfig.cs" +$appConfigPath = "src\TypeGen\TypeGen.Cli\ApplicationConfig.cs" if (Test-Path $appConfigPath) { (Get-Content $appConfigPath).Replace("Version => ""$($oldVersion)""", "Version => ""$($newVersion)""") | Set-Content $appConfigPath } @@ -49,6 +51,16 @@ if (Test-Path $nugetUpdatePath) { (Get-Content $nugetUpdatePath).Replace("TypeGen.$($oldVersion)", "TypeGen.$($newVersion)").Replace("dotnet-typegen.$($oldVersion)", "dotnet-typegen.$($newVersion)") | Set-Content $nugetUpdatePath } +$typeGenCliCsprojPath = "src\TypeGen\TypeGen.Cli\TypeGen.Cli.csproj" +if (Test-Path $typeGenCliCsprojPath) { + (Get-Content $typeGenCliCsprojPath).Replace("$($assemblyOldVersion)", "$($assemblyNewVersion)").Replace("$($assemblyOldVersion)", "$($assemblyNewVersion)") | Set-Content $typeGenCliCsprojPath +} + +$typeGenCoreCsprojPath = "src\TypeGen\TypeGen.Core\TypeGen.Core.csproj" +if (Test-Path $typeGenCoreCsprojPath) { + (Get-Content $typeGenCoreCsprojPath).Replace("$($assemblyOldVersion)", "$($assemblyNewVersion)").Replace("$($assemblyOldVersion)", "$($assemblyNewVersion)") | Set-Content $typeGenCoreCsprojPath +} + # remove old NuGet package $oldNupkgPath = "nuget\TypeGen.$($oldVersion).nupkg" From a60b556152eccbde46959662a5acc835a6e648d3 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Sun, 27 Aug 2023 02:48:58 +0200 Subject: [PATCH 12/16] changed to System.CommandLine for parsing args; TypeGen.Cli design improvements --- .../TypeGen.Cli.Test/ApplicationTest.cs | 44 ++++ .../Business/ConsoleArgsReaderTest.cs | 232 ------------------ .../GeneratorOptionsProviderTest.cs | 14 +- .../TgConfigTest.cs | 10 +- src/TypeGen/TypeGen.Cli/Application.cs | 129 ++++++++++ src/TypeGen/TypeGen.Cli/ApplicationConfig.cs | 13 +- .../TypeGen.Cli/Build/IProjectBuild.cs | 6 + src/TypeGen/TypeGen.Cli/Build/ProjectBuild.cs | 2 +- .../TypeGen.Cli/Business/ConsoleArgsReader.cs | 55 ----- .../ServiceCollectionExtensions.cs | 24 ++ src/TypeGen/TypeGen.Cli/ExitCode.cs | 2 +- .../TypeGen.Cli/Extensions/PathExtensions.cs | 11 +- .../TypeGen.Cli/Extensions/TypeExtensions.cs | 15 ++ .../GenerationConfig/ConfigConsoleOptions.cs | 3 + .../ConfigProvider.cs | 51 ++-- .../GeneratorOptionsProvider.cs | 23 +- .../IConfigProvider.cs | 5 +- .../IGeneratorOptionsProvider.cs | 18 ++ .../TgConfig.cs | 2 +- src/TypeGen/TypeGen.Cli/IApplication.cs | 8 + src/TypeGen/TypeGen.Cli/Program.cs | 218 ++-------------- .../IProjectFileManager.cs | 8 +- .../ProjectFileManager.cs | 27 +- src/TypeGen/TypeGen.Cli/TypeGen.Cli.csproj | 4 + .../IGeneratorOptionsProvider.cs | 18 -- .../TypeResolution/AssemblyResolver.cs | 36 +-- .../TypeResolution/ConverterResolver.cs | 25 ++ .../TypeResolution/GenerationSpecResolver.cs | 25 ++ .../TypeResolution/IAssemblyResolver.cs | 11 - .../TypeResolution/IConverterResolver.cs | 8 + .../TypeResolution/IGenerationSpecResolver.cs | 9 + src/TypeGen/TypeGen.Cli/Ui/ActionResult.cs | 13 + src/TypeGen/TypeGen.Cli/Ui/ConsoleOutput.cs | 46 ++++ src/TypeGen/TypeGen.Cli/Ui/IConsoleOutput.cs | 12 + src/TypeGen/TypeGen.Cli/Ui/IPresenter.cs | 9 + src/TypeGen/TypeGen.Cli/Ui/Presenter.cs | 133 ++++++++++ .../Ui/Validation/GenerateValidator.cs | 21 ++ .../Ui/Validation/IGenerateValidator.cs | 8 + .../Ui/Validation/ValidationResult.cs | 36 +++ .../Extensions/EnumerableExtensions.cs | 9 + .../TypeGen.Core/Logging/ConsoleLogger.cs | 31 +-- src/TypeGen/TypeGen.Core/Logging/ILogger.cs | 1 + .../TypeGen.Core/Utils/ConsoleUtils.cs | 14 ++ update-version.ps1 | 41 +++- 44 files changed, 781 insertions(+), 649 deletions(-) create mode 100644 src/TypeGen/TypeGen.Cli.Test/ApplicationTest.cs delete mode 100644 src/TypeGen/TypeGen.Cli.Test/Business/ConsoleArgsReaderTest.cs rename src/TypeGen/TypeGen.Cli.Test/{Business => GenerationConfig}/GeneratorOptionsProviderTest.cs (85%) rename src/TypeGen/TypeGen.Cli.Test/{Models => GenerationConfig}/TgConfigTest.cs (92%) create mode 100644 src/TypeGen/TypeGen.Cli/Application.cs create mode 100644 src/TypeGen/TypeGen.Cli/Build/IProjectBuild.cs delete mode 100644 src/TypeGen/TypeGen.Cli/Business/ConsoleArgsReader.cs create mode 100644 src/TypeGen/TypeGen.Cli/DependencyInjection/ServiceCollectionExtensions.cs create mode 100644 src/TypeGen/TypeGen.Cli/Extensions/TypeExtensions.cs create mode 100644 src/TypeGen/TypeGen.Cli/GenerationConfig/ConfigConsoleOptions.cs rename src/TypeGen/TypeGen.Cli/{TypeGenConfig => GenerationConfig}/ConfigProvider.cs (77%) rename src/TypeGen/TypeGen.Cli/{TypeGenConfig => GenerationConfig}/GeneratorOptionsProvider.cs (84%) rename src/TypeGen/TypeGen.Cli/{TypeGenConfig => GenerationConfig}/IConfigProvider.cs (72%) create mode 100644 src/TypeGen/TypeGen.Cli/GenerationConfig/IGeneratorOptionsProvider.cs rename src/TypeGen/TypeGen.Cli/{TypeGenConfig => GenerationConfig}/TgConfig.cs (99%) create mode 100644 src/TypeGen/TypeGen.Cli/IApplication.cs delete mode 100644 src/TypeGen/TypeGen.Cli/TypeGenConfig/IGeneratorOptionsProvider.cs create mode 100644 src/TypeGen/TypeGen.Cli/TypeResolution/ConverterResolver.cs create mode 100644 src/TypeGen/TypeGen.Cli/TypeResolution/GenerationSpecResolver.cs delete mode 100644 src/TypeGen/TypeGen.Cli/TypeResolution/IAssemblyResolver.cs create mode 100644 src/TypeGen/TypeGen.Cli/TypeResolution/IConverterResolver.cs create mode 100644 src/TypeGen/TypeGen.Cli/TypeResolution/IGenerationSpecResolver.cs create mode 100644 src/TypeGen/TypeGen.Cli/Ui/ActionResult.cs create mode 100644 src/TypeGen/TypeGen.Cli/Ui/ConsoleOutput.cs create mode 100644 src/TypeGen/TypeGen.Cli/Ui/IConsoleOutput.cs create mode 100644 src/TypeGen/TypeGen.Cli/Ui/IPresenter.cs create mode 100644 src/TypeGen/TypeGen.Cli/Ui/Presenter.cs create mode 100644 src/TypeGen/TypeGen.Cli/Ui/Validation/GenerateValidator.cs create mode 100644 src/TypeGen/TypeGen.Cli/Ui/Validation/IGenerateValidator.cs create mode 100644 src/TypeGen/TypeGen.Cli/Ui/Validation/ValidationResult.cs create mode 100644 src/TypeGen/TypeGen.Core/Utils/ConsoleUtils.cs diff --git a/src/TypeGen/TypeGen.Cli.Test/ApplicationTest.cs b/src/TypeGen/TypeGen.Cli.Test/ApplicationTest.cs new file mode 100644 index 00000000..ea152c8a --- /dev/null +++ b/src/TypeGen/TypeGen.Cli.Test/ApplicationTest.cs @@ -0,0 +1,44 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using NSubstitute; +using TypeGen.Cli.Ui; +using TypeGen.Core.Logging; +using Xunit; + +namespace TypeGen.Cli.Test; + +public class ApplicationTest +{ + [Fact] + public async Task Run_CommandIsGetCwd_CorrectPresenterMethodCalled() + { + // arrange + var args = new[] { "getcwd" }; + var logger = Substitute.For(); + var presenter = Substitute.For(); + var sut = new Application(logger, presenter); + + // act + await sut.Run(args); + + // assert + presenter.Received(1).GetCwd(); + } + + [Fact] + public async Task Run_CommandIsGenerate_CorrectPresenterMethodCalled() + { + // arrange + var args = new[] { "generate" }; + var logger = Substitute.For(); + var presenter = Substitute.For(); + var sut = new Application(logger, presenter); + + // act + await sut.Run(args); + + // assert + presenter.Received(1).Generate(Arg.Any(), Arg.Any>(), + Arg.Any>(), Arg.Any()); + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli.Test/Business/ConsoleArgsReaderTest.cs b/src/TypeGen/TypeGen.Cli.Test/Business/ConsoleArgsReaderTest.cs deleted file mode 100644 index ea0597e7..00000000 --- a/src/TypeGen/TypeGen.Cli.Test/Business/ConsoleArgsReaderTest.cs +++ /dev/null @@ -1,232 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using TypeGen.Cli.Business; -using Xunit; - -namespace TypeGen.Cli.Test.Business -{ - public class ConsoleArgsReaderTest - { - [Theory] - [MemberData(nameof(ContainsGetCwdCommand_TestData))] - public void ContainsGetCwdCommand_Test(string[] args, bool expectedResult) - { - bool actualResult = ConsoleArgsReader.ContainsGetCwdCommand(args); - Assert.Equal(expectedResult, actualResult); - } - - public static IEnumerable ContainsGetCwdCommand_TestData = new[] - { - new object[] { new[] { "asdf", "getcwd", "d" }, true }, - new object[] { new[] { "asdf", "GETCWD", "d" }, true }, - new object[] { new[] { "asdf", "GeTCwD", "d" }, true }, - new object[] { new[] { "getcwd" }, true }, - new object[] { new[] { "asdf", "d" }, false }, - new object[] { new string[] {}, false } - }; - - [Theory] - [MemberData(nameof(ContainsGenerateCommand_TestData))] - public void ContainsGenerateCommand_Test(string[] args, bool expectedResult) - { - bool actualResult = ConsoleArgsReader.ContainsGenerateCommand(args); - Assert.Equal(expectedResult, actualResult); - } - - public static IEnumerable ContainsGenerateCommand_TestData = new[] - { - new object[] { new[] { "asdf", "generate", "d" }, true }, - new object[] { new[] { "asdf", "GENERATE", "d" }, true }, - new object[] { new[] { "asdf", "GeNeRAtE", "d" }, true }, - new object[] { new[] { "generate" }, true }, - new object[] { new[] { "asdf", "d" }, false }, - new object[] { new string[] {}, false } - }; - - [Theory] - [MemberData(nameof(ContainsAnyCommand_TestData))] - public void ContainsAnyCommand_Test(string[] args, bool expectedResult) - { - bool actualResult = ConsoleArgsReader.ContainsAnyCommand(args); - Assert.Equal(expectedResult, actualResult); - } - - public static IEnumerable ContainsAnyCommand_TestData = new[] - { - new object[] { new[] { "asdf", "generate", "d" }, true }, - new object[] { new[] { "asdf", "GetCWD", "d" }, true }, - new object[] { new[] { "asdf", "GeNeRAtE", "gETcwd" }, true }, - new object[] { new[] { "generate" }, true }, - new object[] { new[] { "generatea" }, false }, - new object[] { new[] { "getcwd" }, true }, - new object[] { new[] { "agetcwd" }, false }, - new object[] { new[] { "agenerate" }, false }, - new object[] { new[] { "getcwda" }, false }, - new object[] { new[] { "-getcwd" }, false }, - new object[] { new[] { "-generate" }, false }, - new object[] { new[] { "asdf", "d" }, false }, - new object[] { new string[] {}, false } - }; - - [Theory] - [MemberData(nameof(ContainsHelpOption_TestData))] - public void ContainsHelpOption_Test(string[] args, bool expectedResult) - { - bool actualResult = ConsoleArgsReader.ContainsHelpOption(args); - Assert.Equal(expectedResult, actualResult); - } - - public static IEnumerable ContainsHelpOption_TestData = new[] - { - new object[] { new[] { "asdf", "-h", "d" }, true }, - new object[] { new[] { "asdf", "--help", "d" }, true }, - new object[] { new[] { "asdf", "-H", "d" }, true }, - new object[] { new[] { "asdf", "--HELP", "d" }, true }, - new object[] { new[] { "asdf", "--HeLp", "d" }, true }, - new object[] { new[] { "-h" }, true }, - new object[] { new[] { "--help" }, true }, - new object[] { new[] { "asdf", "d" }, false }, - new object[] { new string[] {}, false } - }; - - [Theory] - [MemberData(nameof(ContainsProjectFolderOption_TestData))] - public void ContainsProjectFolderOption_Test(string[] args, bool expectedResult) - { - bool actualResult = ConsoleArgsReader.ContainsProjectFolderOption(args); - Assert.Equal(expectedResult, actualResult); - } - - public static IEnumerable ContainsProjectFolderOption_TestData = new[] - { - new object[] { new[] { "asdf", "-p", "d" }, true }, - new object[] { new[] { "asdf", "--project-folder", "d" }, true }, - new object[] { new[] { "asdf", "-P", "d" }, true }, - new object[] { new[] { "asdf", "--PROJECT-FOLDER", "d" }, true }, - new object[] { new[] { "asdf", "--PrOjECt-FoldER", "d" }, true }, - new object[] { new[] { "-p" }, true }, - new object[] { new[] { "--project-folder" }, true }, - new object[] { new[] { "asdf", "d" }, false }, - new object[] { new string[] {}, false } - }; - - [Theory] - [MemberData(nameof(ContainsOutputFolderOption_TestData))] - public void ContainsOutputFolderOption_Test(string[] args, bool expectedResult) - { - bool actualResult = ConsoleArgsReader.ContainsOutputOption(args); - Assert.Equal(expectedResult, actualResult); - } - - public static IEnumerable ContainsOutputFolderOption_TestData = new[] - { - new object[] { new[] { "asdf", "-o", "d" }, true }, - new object[] { new[] { "asdf", "--output-folder", "d" }, true }, - new object[] { new[] { "asdf", "-O", "d" }, true }, - new object[] { new[] { "asdf", "--OUTPUT-FOLDER", "d" }, true }, - new object[] { new[] { "asdf", "--OuTpUt-FoldER", "d" }, true }, - new object[] { new[] { "-o" }, true }, - new object[] { new[] { "--output-folder" }, true }, - new object[] { new[] { "asdf", "d" }, false }, - new object[] { new string[] {}, false } - }; - - [Theory] - [MemberData(nameof(ContainsVerboseOption_TestData))] - public void ContainsVerboseOption_Test(string[] args, bool expectedResult) - { - bool actualResult = ConsoleArgsReader.ContainsVerboseOption(args); - Assert.Equal(expectedResult, actualResult); - } - - public static IEnumerable ContainsVerboseOption_TestData = new[] - { - new object[] { new[] { "asdf", "-v", "d" }, true }, - new object[] { new[] { "asdf", "--verbose", "d" }, true }, - new object[] { new[] { "asdf", "-V", "d" }, true }, - new object[] { new[] { "asdf", "--VERBOSE", "d" }, true }, - new object[] { new[] { "asdf", "--VeRbOSE", "d" }, true }, - new object[] { new[] { "-v" }, true }, - new object[] { new[] { "--verbose" }, true }, - new object[] { new[] { "asdf", "d" }, false }, - new object[] { new string[] {}, false } - }; - - [Theory] - [MemberData(nameof(GetProjectFolders_TestData))] - public void GetProjectFolders_Test(string[] args, IEnumerable expectedResult) - { - IEnumerable actualResult = ConsoleArgsReader.GetProjectFolders(args); - Assert.Equal(expectedResult, actualResult); - } - - public static IEnumerable GetProjectFolders_TestData = new[] - { - new object[] { new[] { "-p", "asdf", "project/folder" }, new [] { "asdf" } }, - new object[] { new[] { "--project-folder", "asdf", @"C:\project\folder" }, new [] { "asdf" } }, - new object[] { new[] { "-p", "asdf|qwer", "--config-path", "zxcv" }, new [] { "asdf", "qwer" } }, - new object[] { new[] { "--project-folder", @"D:\my\folder|some/other/folder|that/folder", "--config-path", "zxcv|qwer" }, new [] { @"D:\my\folder", "some/other/folder", "that/folder" } }, - new object[] { new[] { "asdf" }, new string[] {} }, - new object[] { new string[] {}, new string[] {} } - }; - - [Fact] - public void GetProjectFolders_ParameterPresentAndNoPathsSpecified_ExceptionThrown() - { - var args = new[] { "--project-folder" }; - Assert.Throws(() => ConsoleArgsReader.GetProjectFolders(args)); - } - - [Theory] - [MemberData(nameof(GetOutputFolder_TestData))] - public void GetOutputFolder_Test(string[] args, string expectedResult) - { - string actualResult = ConsoleArgsReader.GetOutputFolder(args); - Assert.Equal(expectedResult, actualResult); - } - - public static IEnumerable GetOutputFolder_TestData = new[] - { - new object[] { new[] { "-o", "asdf", "project/folder" }, "asdf" }, - new object[] { new[] { "--output-folder", "asdf", @"C:\project\folder" }, "asdf" }, - new object[] { new[] { "-o", "asdf|qwer", "--config-path", "zxcv" }, "asdf" }, - new object[] { new[] { "--output-folder", @"D:\my\folder|some/other/folder|that/folder", "--config-path", "zxcv|qwer" }, @"D:\my\folder" }, - new object[] { new[] { "asdf" }, null }, - new object[] { new string[] {}, null } - }; - - [Fact] - public void GetOutputFolder_ParameterPresentAndNoPathsSpecified_ExceptionThrown() - { - var args = new[] { "--output-folder" }; - Assert.Throws(() => ConsoleArgsReader.GetOutputFolder(args)); - } - - [Theory] - [MemberData(nameof(GetConfigPaths_TestData))] - public void GetConfigPaths_Test(string[] args, IEnumerable expectedResult) - { - IEnumerable actualResult = ConsoleArgsReader.GetConfigPaths(args); - Assert.Equal(expectedResult, actualResult); - } - - public static IEnumerable GetConfigPaths_TestData = new[] - { - new object[] { new[] { "asdf", "-c", "zxcv" }, new [] { "zxcv" } }, - new object[] { new[] { "asdf", "--config-path", "zxcv" }, new [] { "zxcv" } }, - new object[] { new[] { "asdf", "-c", "zxcv", "qwer" }, new [] { "zxcv" } }, - new object[] { new[] { "asdf", "--config-path", "zxcv|qwer" }, new [] { "zxcv", "qwer" } }, - new object[] { new[] { "asdf", "-c", @"my\path|C:\Program Files\path" }, new [] { @"my\path", @"C:\Program Files\path" } }, - new object[] { new[] { "asdf", "--config-path", @"my\path|C:\Program Files\path|other/path" }, new [] { @"my\path", @"C:\Program Files\path", "other/path" } }, - new object[] { new[] { "asdf" }, new string[] {} }, - new object[] { new string[] {}, new string[] {} } - }; - - [Fact] - public void GetConfigPaths_ParameterPresentAndNoPathsSpecified_ExceptionThrown() - { - var args = new[] { "--config-path" }; - Assert.Throws(() => ConsoleArgsReader.GetConfigPaths(args)); - } - } -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs b/src/TypeGen/TypeGen.Cli.Test/GenerationConfig/GeneratorOptionsProviderTest.cs similarity index 85% rename from src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs rename to src/TypeGen/TypeGen.Cli.Test/GenerationConfig/GeneratorOptionsProviderTest.cs index 5810741c..92c6290d 100644 --- a/src/TypeGen/TypeGen.Cli.Test/Business/GeneratorOptionsProviderTest.cs +++ b/src/TypeGen/TypeGen.Cli.Test/GenerationConfig/GeneratorOptionsProviderTest.cs @@ -1,16 +1,14 @@ using System; -using System.Collections.Generic; using System.Linq; using System.Reflection; using FluentAssertions; using NSubstitute; -using TypeGen.Cli.Business; -using TypeGen.Cli.TypeGenConfig; +using TypeGen.Cli.GenerationConfig; using TypeGen.Cli.TypeResolution; using TypeGen.Core.Generator; using Xunit; -namespace TypeGen.Cli.Test.Business; +namespace TypeGen.Cli.Test.GenerationConfig; public class GeneratorOptionsProviderTest { @@ -24,8 +22,8 @@ public void GetGeneratorOptions_Should_ConcatenateBlacklists() tgConfig.TypeBlacklist = tgConfigBlacklist; var expected = GeneratorOptions.DefaultTypeBlacklist.Concat(tgConfigBlacklist); - var typeResolver = Substitute.For(); - var sut = new GeneratorOptionsProvider(typeResolver); + var converterResolver = Substitute.For(); + var sut = new GeneratorOptionsProvider(converterResolver); // act var actual = sut.GetGeneratorOptions(tgConfig, Enumerable.Empty(), projectFolder) @@ -47,8 +45,8 @@ public void GetGeneratorOptions_WhitelistGiven_WhitelistRemovesTypesFromBlacklis tgConfig.TypeWhitelist = tgConfigWhitelist; var expected = GeneratorOptions.DefaultTypeBlacklist.Concat(tgConfigBlacklist).Except(tgConfigWhitelist); - var typeResolver = Substitute.For(); - var sut = new GeneratorOptionsProvider(typeResolver); + var converterResolver = Substitute.For(); + var sut = new GeneratorOptionsProvider(converterResolver); // act var actual = sut.GetGeneratorOptions(tgConfig, Enumerable.Empty(), projectFolder) diff --git a/src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs b/src/TypeGen/TypeGen.Cli.Test/GenerationConfig/TgConfigTest.cs similarity index 92% rename from src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs rename to src/TypeGen/TypeGen.Cli.Test/GenerationConfig/TgConfigTest.cs index d7364ae8..2bcf7f5c 100644 --- a/src/TypeGen/TypeGen.Cli.Test/Models/TgConfigTest.cs +++ b/src/TypeGen/TypeGen.Cli.Test/GenerationConfig/TgConfigTest.cs @@ -1,12 +1,8 @@ -using System.Linq; -using FluentAssertions; -using TypeGen.Core; +using FluentAssertions; +using TypeGen.Cli.GenerationConfig; using Xunit; -using TypeGen.Cli.Extensions; -using TypeGen.Cli.TypeGenConfig; -using TypeGen.Core.Extensions; -namespace TypeGen.Cli.Test.Models +namespace TypeGen.Cli.Test.GenerationConfig { public class TgConfigTest { diff --git a/src/TypeGen/TypeGen.Cli/Application.cs b/src/TypeGen/TypeGen.Cli/Application.cs new file mode 100644 index 00000000..0c97735e --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Application.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.CommandLine; +using System.CommandLine.Builder; +using System.CommandLine.Help; +using System.CommandLine.Invocation; +using System.CommandLine.Parsing; +using System.Linq; +using System.Reflection; +using System.Threading.Tasks; +using TypeGen.Cli.Ui; +using TypeGen.Core; +using TypeGen.Core.Logging; + +namespace TypeGen.Cli; + +internal class Application : IApplication +{ + private readonly ILogger _logger; + private readonly IPresenter _presenter; + + private ExitCode _exitCode = ExitCode.Success; + + public Application(ILogger logger, IPresenter presenter) + { + _logger = logger; + _presenter = presenter; + } + + public async Task Run(string[] args) + { + try + { + var parser = BuildCommandLine(); + await parser.InvokeAsync(args); + return _exitCode; + } + catch (AssemblyResolutionException e) + { + var message = e.Message + + "Consider adding any external assembly directories in the externalAssemblyPaths parameter. " + + "If you're using ASP.NET Core, add your NuGet directory to externalAssemblyPaths parameter (you can use global NuGet packages directory alias: \"\")"; + _logger.Log($"{message}{Environment.NewLine}{e.StackTrace}", LogLevel.Error); + return ExitCode.Error; + } + catch (ReflectionTypeLoadException e) + { + foreach (var loaderException in e.LoaderExceptions) + { + _logger.Log($"Type load error: {loaderException.Message}{Environment.NewLine}{e.StackTrace}", LogLevel.Error); + } + return ExitCode.Error; + } + catch (Exception e) + { + _logger.Log($"{e.Message}{Environment.NewLine}{e.StackTrace}", LogLevel.Error); + return ExitCode.Error; + } + } + + private Parser BuildCommandLine() + { + var rootCommand = new RootCommand + { + Name = "[dotnet-]typegen" + }; + + var generateCommand = new Command("generate", "Generate TypeScript sources"); + + var verboseOption = new Option + (name: "--verbose", + description: "Show verbose output", + getDefaultValue: () => false); + verboseOption.AddAlias("-v"); + + var projectFolderOption = new Option> + (name: "--project-folder", + description: "The project folder path(s)"); + projectFolderOption.AddAlias("-p"); + + var configPathOption = new Option> + (name: "--config-path", + description: "The config file path(s)"); + configPathOption.AddAlias("-c"); + + var outputFolderOption = new Option + (name: "--output-folder", + description: "Project's output folder"); + configPathOption.AddAlias("-o"); + + generateCommand.AddOption(verboseOption); + generateCommand.AddOption(projectFolderOption); + generateCommand.AddOption(configPathOption); + generateCommand.AddOption(outputFolderOption); + + generateCommand.SetHandler((v, p, c, o) => + { + _exitCode = ExitCodeFromActionResult(_presenter.Generate(v, p, c, o)); + }, + verboseOption, + projectFolderOption, + configPathOption, + outputFolderOption); + + var getCwdCommand = new Command("getcwd", "Get current working directory"); + getCwdCommand.SetHandler(() => + { + _exitCode = ExitCodeFromActionResult(_presenter.GetCwd()); + }); + + rootCommand.AddCommand(generateCommand); + rootCommand.AddCommand(getCwdCommand); + + return new CommandLineBuilder(rootCommand) + .UseDefaults() + .UseHelp(ctx => ctx.HelpBuilder.CustomizeLayout( + _ => HelpBuilder.Default + .GetLayout() + .Skip(1) + .Prepend(_ => + { + Console.WriteLine($"TypeGen v{ApplicationConfig.Version}"); + }))) + .Build(); + } + + private static ExitCode ExitCodeFromActionResult(ActionResult actionResult) => + actionResult.IsSuccess ? ExitCode.Success : ExitCode.Error; +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/ApplicationConfig.cs b/src/TypeGen/TypeGen.Cli/ApplicationConfig.cs index 591dc110..ed529414 100644 --- a/src/TypeGen/TypeGen.Cli/ApplicationConfig.cs +++ b/src/TypeGen/TypeGen.Cli/ApplicationConfig.cs @@ -1,13 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +namespace TypeGen.Cli; -namespace TypeGen.Cli +internal class ApplicationConfig { - internal class ApplicationConfig - { - public static string Version => "4.5.0"; - } + public const string Version = "4.5.0"; } diff --git a/src/TypeGen/TypeGen.Cli/Build/IProjectBuild.cs b/src/TypeGen/TypeGen.Cli/Build/IProjectBuild.cs new file mode 100644 index 00000000..a36ba649 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Build/IProjectBuild.cs @@ -0,0 +1,6 @@ +namespace TypeGen.Cli.Build; + +internal interface IProjectBuild +{ + void Build(string projectFolder); +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Build/ProjectBuild.cs b/src/TypeGen/TypeGen.Cli/Build/ProjectBuild.cs index 74315f39..2e0a3f00 100644 --- a/src/TypeGen/TypeGen.Cli/Build/ProjectBuild.cs +++ b/src/TypeGen/TypeGen.Cli/Build/ProjectBuild.cs @@ -4,7 +4,7 @@ namespace TypeGen.Cli.Build { - internal class ProjectBuild + internal class ProjectBuild : IProjectBuild { private readonly ILogger _logger; diff --git a/src/TypeGen/TypeGen.Cli/Business/ConsoleArgsReader.cs b/src/TypeGen/TypeGen.Cli/Business/ConsoleArgsReader.cs deleted file mode 100644 index 0a040418..00000000 --- a/src/TypeGen/TypeGen.Cli/Business/ConsoleArgsReader.cs +++ /dev/null @@ -1,55 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using TypeGen.Core.Extensions; - -namespace TypeGen.Cli.Business -{ - internal class ConsoleArgsReader - { - private const string GetCwdCommand = "GETCWD"; - private const string GenerateCommand = "GENERATE"; - - /// - /// Used to separate two or more paths; not a directory separator - /// - private const string PathSeparator = "|"; - - public static bool ContainsGetCwdCommand(string[] args) => ContainsCommand(args, GetCwdCommand); - public static bool ContainsGenerateCommand(string[] args) => ContainsCommand(args, GenerateCommand); - public static bool ContainsAnyCommand(string[] args) => ContainsGenerateCommand(args) || ContainsGetCwdCommand(args); - private static bool ContainsCommand(string[] args, string command) => args.Any(arg => string.Equals(arg, command, StringComparison.InvariantCultureIgnoreCase)); - - public static bool ContainsHelpOption(string[] args) => ContainsOption(args, "-h", "--help"); - public static bool ContainsProjectFolderOption(string[] args) => ContainsOption(args, "-p", "--project-folder"); - public static bool ContainsOutputOption(string[] args) => ContainsOption(args, "-o", "--output-folder"); - public static bool ContainsVerboseOption(string[] args) => ContainsOption(args, "-v", "--verbose"); - private static bool ContainsOption(string[] args, string optionShortName, string optionFullName) => args.Any(arg => string.Equals(arg, optionShortName, StringComparison.InvariantCultureIgnoreCase) || string.Equals(arg, optionFullName, StringComparison.InvariantCultureIgnoreCase)); - - public static IEnumerable GetProjectFolders(string[] args) => GetPathsParam(args, "-p", "--project-folder"); - public static string GetOutputFolder(string[] args) => GetPathsParam(args, "-o", "--output-folder").FirstOrDefault(); - public static IEnumerable GetConfigPaths(string[] args) => GetPathsParam(args, "-c", "--config-path"); - - private static IEnumerable GetPathsParam(string[] args, string paramShortName, string paramFullName) - { - int index = -1; - - for (var i = 0; i < args.Length; i++) - { - if (args[i].Equals(paramShortName, StringComparison.InvariantCultureIgnoreCase) || - args[i].Equals(paramFullName, StringComparison.InvariantCultureIgnoreCase)) - { - index = i; - break; - } - } - - if (index < 0) return Enumerable.Empty(); - - if (args.Length < index + 2) throw new CliException($"{paramShortName}|{paramFullName} parameter present, but no path specified"); - return args[index + 1].Split(PathSeparator); - } - } -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/DependencyInjection/ServiceCollectionExtensions.cs b/src/TypeGen/TypeGen.Cli/DependencyInjection/ServiceCollectionExtensions.cs new file mode 100644 index 00000000..1c803bf7 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/DependencyInjection/ServiceCollectionExtensions.cs @@ -0,0 +1,24 @@ +using System.Linq; +using System.Reflection; +using Microsoft.Extensions.DependencyInjection; +using TypeGen.Cli.Extensions; +using TypeGen.Core.Validation; + +namespace TypeGen.Cli.DependencyInjection; + +internal static class ServiceCollectionExtensions +{ + public static void AddInterfacesWithSingleImplementation(this ServiceCollection @this) + { + Requires.NotNull(@this, nameof(@this)); + + var allTypes = Assembly.GetExecutingAssembly().GetTypes(); + + var typePairs = allTypes.Where(@interface => @interface.IsInterface + && allTypes.Count(@class => @class.IsClass && @class.ImplementsInterface(@interface.FullName)) == 1) + .Select(@interface => (@interface, @class: allTypes.Single(@class => @class.ImplementsInterface(@interface.FullName)))); + + foreach (var pair in typePairs) + @this.AddTransient(pair.@interface, pair.@class); + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/ExitCode.cs b/src/TypeGen/TypeGen.Cli/ExitCode.cs index bd4ef7c9..6477f83f 100644 --- a/src/TypeGen/TypeGen.Cli/ExitCode.cs +++ b/src/TypeGen/TypeGen.Cli/ExitCode.cs @@ -1,6 +1,6 @@ namespace TypeGen.Cli; -public enum ExitCode : int +internal enum ExitCode { Success = 0, Error = 1 diff --git a/src/TypeGen/TypeGen.Cli/Extensions/PathExtensions.cs b/src/TypeGen/TypeGen.Cli/Extensions/PathExtensions.cs index 09943777..aae3c097 100644 --- a/src/TypeGen/TypeGen.Cli/Extensions/PathExtensions.cs +++ b/src/TypeGen/TypeGen.Cli/Extensions/PathExtensions.cs @@ -3,6 +3,7 @@ using System.IO; using System.Text; using TypeGen.Core.Storage; +using TypeGen.Core.Validation; namespace TypeGen.Cli.Extensions { @@ -11,7 +12,15 @@ internal static class PathExtensions public static string ToAbsolutePath(this string path, IFileSystem fileSystem) { if (string.IsNullOrWhiteSpace(path)) return path; - return Path.IsPathRooted(path) ? path : Path.Combine(fileSystem.GetCurrentDirectory(), path); + return path.RelativeOrRooted(fileSystem.GetCurrentDirectory()); + } + + public static string RelativeOrRooted(this string path, string basePath) + { + Requires.NotNull(path, nameof(path)); + Requires.NotNull(basePath, nameof(basePath)); + + return Path.IsPathRooted(path) ? path : Path.Combine(basePath, path); } } } diff --git a/src/TypeGen/TypeGen.Cli/Extensions/TypeExtensions.cs b/src/TypeGen/TypeGen.Cli/Extensions/TypeExtensions.cs new file mode 100644 index 00000000..480f2e52 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Extensions/TypeExtensions.cs @@ -0,0 +1,15 @@ +using System; +using TypeGen.Core.Validation; + +namespace TypeGen.Cli.Extensions; + +internal static class TypeExtensions +{ + public static bool ImplementsInterface(this Type @this, string interfaceName) + { + Requires.NotNull(@this, nameof(@this)); + Requires.NotNullOrEmpty(interfaceName, nameof(interfaceName)); + + return @this.GetInterface(interfaceName) != null; + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/GenerationConfig/ConfigConsoleOptions.cs b/src/TypeGen/TypeGen.Cli/GenerationConfig/ConfigConsoleOptions.cs new file mode 100644 index 00000000..8d1f1c29 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/GenerationConfig/ConfigConsoleOptions.cs @@ -0,0 +1,3 @@ +namespace TypeGen.Cli.GenerationConfig; + +internal record ConfigConsoleOptions(string OutputFolder); \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/TypeGenConfig/ConfigProvider.cs b/src/TypeGen/TypeGen.Cli/GenerationConfig/ConfigProvider.cs similarity index 77% rename from src/TypeGen/TypeGen.Cli/TypeGenConfig/ConfigProvider.cs rename to src/TypeGen/TypeGen.Cli/GenerationConfig/ConfigProvider.cs index e02d37ab..dc86e9e3 100644 --- a/src/TypeGen/TypeGen.Cli/TypeGenConfig/ConfigProvider.cs +++ b/src/TypeGen/TypeGen.Cli/GenerationConfig/ConfigProvider.cs @@ -2,12 +2,12 @@ using System.IO; using System.Linq; using Newtonsoft.Json; -using TypeGen.Cli.Business; +using TypeGen.Cli.Extensions; using TypeGen.Core.Logging; using TypeGen.Core.Storage; using TypeGen.Core.Validation; -namespace TypeGen.Cli.TypeGenConfig +namespace TypeGen.Cli.GenerationConfig { internal class ConfigProvider : IConfigProvider { @@ -22,40 +22,43 @@ public ConfigProvider(IFileSystem fileSystem, } /// - /// Creates a config object from a given config file + /// Creates an instance of TgConfig from /// /// /// + /// /// - public TgConfig GetConfig(string configPath, string projectFolder) + public TgConfig GetConfig(string configPath, string projectFolder, ConfigConsoleOptions consoleOptions) { - Requires.NotNullOrEmpty(configPath, nameof(configPath)); Requires.NotNullOrEmpty(projectFolder, nameof(projectFolder)); - if (!_fileSystem.FileExists(configPath)) - { - _logger.Log($"No config file found for project \"{projectFolder}\". Default configuration will be used.", LogLevel.Debug); - - TgConfig defaultConfig = new TgConfig() - .MergeWithDefaultParams() - .Normalize(); - - UpdateConfigAssemblyPaths(defaultConfig, projectFolder); - return defaultConfig; - } - - _logger.Log($"Reading the config file from \"{configPath}\"", LogLevel.Debug); - - string tgConfigJson = _fileSystem.ReadFile(configPath); - TgConfig config = JsonConvert.DeserializeObject(tgConfigJson) - .MergeWithDefaultParams() - .Normalize(); + configPath = !string.IsNullOrEmpty(configPath) + ? configPath.RelativeOrRooted(projectFolder) + : "tgconfig.json".RelativeOrRooted(projectFolder); + + _logger.Log(_fileSystem.FileExists(configPath) + ? $"Reading the config file from \"{configPath}\"" + : $"No config file found for project \"{projectFolder}\". Default configuration will be used.", + LogLevel.Debug); + + var config = _fileSystem.FileExists(configPath) + ? JsonConvert.DeserializeObject(_fileSystem.ReadFile(configPath)) + : new TgConfig(); + OverrideWithConsoleOptions(config, consoleOptions); + config.MergeWithDefaultParams(); + config.Normalize(); + UpdateConfigAssemblyPaths(config, projectFolder); - + return config; } + private static void OverrideWithConsoleOptions(TgConfig config, ConfigConsoleOptions consoleOptions) + { + if (consoleOptions.OutputFolder != null) config.OutputPath = consoleOptions.OutputFolder; + } + private void UpdateConfigAssemblyPaths(TgConfig config, string projectFolder) { if (!string.IsNullOrEmpty(config.AssemblyPath)) diff --git a/src/TypeGen/TypeGen.Cli/TypeGenConfig/GeneratorOptionsProvider.cs b/src/TypeGen/TypeGen.Cli/GenerationConfig/GeneratorOptionsProvider.cs similarity index 84% rename from src/TypeGen/TypeGen.Cli/TypeGenConfig/GeneratorOptionsProvider.cs rename to src/TypeGen/TypeGen.Cli/GenerationConfig/GeneratorOptionsProvider.cs index a351d5ff..b8d5cb23 100644 --- a/src/TypeGen/TypeGen.Cli/TypeGenConfig/GeneratorOptionsProvider.cs +++ b/src/TypeGen/TypeGen.Cli/GenerationConfig/GeneratorOptionsProvider.cs @@ -2,22 +2,21 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using TypeGen.Cli.Business; using TypeGen.Cli.Extensions; using TypeGen.Cli.TypeResolution; using TypeGen.Core.Converters; using TypeGen.Core.Generator; using TypeGen.Core.Validation; -namespace TypeGen.Cli.TypeGenConfig +namespace TypeGen.Cli.GenerationConfig { internal class GeneratorOptionsProvider : IGeneratorOptionsProvider { - private readonly ITypeResolver _typeResolver; + private readonly IConverterResolver _converterResolver; - public GeneratorOptionsProvider(ITypeResolver typeResolver) + public GeneratorOptionsProvider(IConverterResolver converterResolver) { - _typeResolver = typeResolver; + _converterResolver = converterResolver; } /// @@ -26,6 +25,7 @@ public GeneratorOptionsProvider(ITypeResolver typeResolver) /// /// /// + /// /// public GeneratorOptions GetGeneratorOptions(TgConfig config, IEnumerable assemblies, string projectFolder) { @@ -35,6 +35,7 @@ public GeneratorOptions GetGeneratorOptions(TgConfig config, IEnumerable GetTypeBlacklist(string[] configTypeBlacklist, st private TypeNameConverterCollection GetTypeNameConvertersFromConfig(IEnumerable typeNameConverters) { - IEnumerable converters = GetConverters(typeNameConverters); + var converters = _converterResolver.Resolve(typeNameConverters); return new TypeNameConverterCollection(converters); } private MemberNameConverterCollection GetMemberNameConvertersFromConfig(IEnumerable nameConverters) { - IEnumerable converters = GetConverters(nameConverters); + IEnumerable converters = _converterResolver.Resolve(nameConverters); return new MemberNameConverterCollection(converters); } - - private IEnumerable GetConverters(IEnumerable converters) - { - return converters - .Select(name => _typeResolver.Resolve(name, "Converter", new[] { typeof(T) })) - .Where(t => t != null) - .Select(t => (T)Activator.CreateInstance(t)); - } } } diff --git a/src/TypeGen/TypeGen.Cli/TypeGenConfig/IConfigProvider.cs b/src/TypeGen/TypeGen.Cli/GenerationConfig/IConfigProvider.cs similarity index 72% rename from src/TypeGen/TypeGen.Cli/TypeGenConfig/IConfigProvider.cs rename to src/TypeGen/TypeGen.Cli/GenerationConfig/IConfigProvider.cs index c97a25f8..f5b7a8d3 100644 --- a/src/TypeGen/TypeGen.Cli/TypeGenConfig/IConfigProvider.cs +++ b/src/TypeGen/TypeGen.Cli/GenerationConfig/IConfigProvider.cs @@ -1,4 +1,4 @@ -namespace TypeGen.Cli.TypeGenConfig +namespace TypeGen.Cli.GenerationConfig { internal interface IConfigProvider { @@ -7,7 +7,8 @@ internal interface IConfigProvider /// /// /// + /// /// - TgConfig GetConfig(string configPath, string projectFolder); + TgConfig GetConfig(string configPath, string projectFolder, ConfigConsoleOptions consoleOptions); } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/GenerationConfig/IGeneratorOptionsProvider.cs b/src/TypeGen/TypeGen.Cli/GenerationConfig/IGeneratorOptionsProvider.cs new file mode 100644 index 00000000..15141ae5 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/GenerationConfig/IGeneratorOptionsProvider.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Reflection; +using TypeGen.Core.Generator; + +namespace TypeGen.Cli.GenerationConfig; + +internal interface IGeneratorOptionsProvider +{ + /// + /// Returns the GeneratorOptions object based on the passed ConfigParams + /// + /// + /// + /// + /// + /// + GeneratorOptions GetGeneratorOptions(TgConfig config, IEnumerable assemblies, string projectFolder); +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/TypeGenConfig/TgConfig.cs b/src/TypeGen/TypeGen.Cli/GenerationConfig/TgConfig.cs similarity index 99% rename from src/TypeGen/TypeGen.Cli/TypeGenConfig/TgConfig.cs rename to src/TypeGen/TypeGen.Cli/GenerationConfig/TgConfig.cs index f1f562b1..8d4e8146 100644 --- a/src/TypeGen/TypeGen.Cli/TypeGenConfig/TgConfig.cs +++ b/src/TypeGen/TypeGen.Cli/GenerationConfig/TgConfig.cs @@ -5,7 +5,7 @@ using TypeGen.Core.Extensions; using TypeGen.Core.Generator; -namespace TypeGen.Cli.TypeGenConfig +namespace TypeGen.Cli.GenerationConfig { /// /// Represents console configuration diff --git a/src/TypeGen/TypeGen.Cli/IApplication.cs b/src/TypeGen/TypeGen.Cli/IApplication.cs new file mode 100644 index 00000000..3185c991 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/IApplication.cs @@ -0,0 +1,8 @@ +using System.Threading.Tasks; + +namespace TypeGen.Cli; + +internal interface IApplication +{ + Task Run(string[] args); +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Program.cs b/src/TypeGen/TypeGen.Cli/Program.cs index 81e1bf6d..271599eb 100644 --- a/src/TypeGen/TypeGen.Cli/Program.cs +++ b/src/TypeGen/TypeGen.Cli/Program.cs @@ -1,212 +1,22 @@ using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Xml; -using TypeGen.Cli.Build; -using TypeGen.Cli.Business; -using TypeGen.Cli.ProjectFileManagement; -using TypeGen.Cli.TypeGenConfig; -using TypeGen.Cli.TypeResolution; -using TypeGen.Core; -using TypeGen.Core.Extensions; -using TypeGen.Core.Generator; +using System.Threading.Tasks; +using Microsoft.Extensions.DependencyInjection; +using TypeGen.Cli.DependencyInjection; using TypeGen.Core.Logging; -using TypeGen.Core.SpecGeneration; using TypeGen.Core.Storage; -using IGeneratorOptionsProvider = TypeGen.Cli.TypeGenConfig.IGeneratorOptionsProvider; -using GeneratorOptionsProvider = TypeGen.Cli.TypeGenConfig.GeneratorOptionsProvider; -namespace TypeGen.Cli +namespace TypeGen.Cli; + +internal class Program { - internal class Program + private static async Task Main(string[] args) { - private static ILogger _logger; - private static IFileSystem _fileSystem; - private static IConfigProvider _configProvider; - private static IGeneratorOptionsProvider _generatorOptionsProvider; - private static IProjectFileManager _projectFileManager; - private static ProjectBuild _projectBuild; - private static IAssemblyResolver _assemblyResolver; - - private static void InitializeServices(string[] args) - { - bool verbose = ConsoleArgsReader.ContainsVerboseOption(args); - _logger = new ConsoleLogger(verbose); - - _fileSystem = new FileSystem(); - _configProvider = new ConfigProvider(_fileSystem, _logger); - _projectFileManager = new ProjectFileManager(_fileSystem); - _projectBuild = new ProjectBuild(_logger); - } - - private static int Main(string[] args) - { - try - { - InitializeServices(args); - - if (args == null || args.Length == 0 || ConsoleArgsReader.ContainsHelpOption(args) || ConsoleArgsReader.ContainsAnyCommand(args) == false) - { - ShowHelp(); - return (int)ExitCode.Success; - } - - if (ConsoleArgsReader.ContainsGetCwdCommand(args)) - { - string cwd = _fileSystem.GetCurrentDirectory(); - Console.WriteLine($"Current working directory is: {cwd}"); - return (int)ExitCode.Success; - } - - string[] configPaths = ConsoleArgsReader.GetConfigPaths(args).ToArray(); - - string[] projectFolders = ConsoleArgsReader.ContainsProjectFolderOption(args) ? - ConsoleArgsReader.GetProjectFolders(args).ToArray() : - new [] { "." }; - - string? outputFolder = ConsoleArgsReader.ContainsOutputOption(args) ? - ConsoleArgsReader.GetOutputFolder(args) : null; - - for (var i = 0; i < projectFolders.Length; i++) - { - string projectFolder = projectFolders[i]; - string configPath = configPaths.HasIndex(i) ? configPaths[i] : null; - - _assemblyResolver = new AssemblyResolver(_fileSystem, _logger, projectFolder); - - Generate(projectFolder, configPath, outputFolder); - } - - return (int)ExitCode.Success; - } - catch (AssemblyResolutionException e) - { - string message = e.Message + - "Consider adding any external assembly directories in the externalAssemblyPaths parameter. " + - "If you're using ASP.NET Core, add your NuGet directory to externalAssemblyPaths parameter (you can use global NuGet packages directory alias: \"\")"; - _logger.Log($"{message}{Environment.NewLine}{e.StackTrace}", LogLevel.Error); - return (int)ExitCode.Error; - } - catch (ReflectionTypeLoadException e) - { - foreach (Exception loaderException in e.LoaderExceptions) - { - _logger.Log($"TYPE LOAD ERROR: {loaderException.Message}{Environment.NewLine}{e.StackTrace}", LogLevel.Error); - } - return (int)ExitCode.Error; - } - catch (Exception e) - { - _logger.Log($"ERROR: {e.Message}{Environment.NewLine}{e.StackTrace}", LogLevel.Error); - return (int)ExitCode.Error; - } - } - - private static void Generate(string projectFolder, string configPath, string? outputFolder) - { - // get config - - configPath = !string.IsNullOrEmpty(configPath) - ? Path.Combine(projectFolder, configPath) - : Path.Combine(projectFolder, "tgconfig.json"); - - TgConfig config = _configProvider.GetConfig(configPath, projectFolder); - - // register assembly resolver - - _assemblyResolver.Directories = config.ExternalAssemblyPaths; - _assemblyResolver.Register(); - - IEnumerable assemblies = GetAssemblies(config.GetAssemblies()).ToArray(); - - // create generator - - var typeResolver = new TypeResolver(_logger, _fileSystem, projectFolder, assemblies); - _generatorOptionsProvider = new GeneratorOptionsProvider(typeResolver); - GeneratorOptions generatorOptions = _generatorOptionsProvider.GetGeneratorOptions(config, assemblies, projectFolder); - generatorOptions.BaseOutputDirectory = outputFolder ?? Path.Combine(projectFolder, config.OutputPath); - var generator = new Generator(generatorOptions, _logger); - - // generate - - if (config.ClearOutputDirectory == true) _fileSystem.ClearDirectory(generatorOptions.BaseOutputDirectory); - if (config.BuildProject == true) _projectBuild.Build(projectFolder); - - _logger.Log($"Generating files for project \"{projectFolder}\"...", LogLevel.Info); - - var generatedFiles = new List(); - - if (!config.GenerationSpecs.Any() || config.GenerateFromAssemblies == true) - { - generatedFiles.AddRange(generator.Generate(assemblies)); - } - - if (config.GenerationSpecs.Any()) - { - IEnumerable generationSpecs = config.GenerationSpecs - .Select(name => typeResolver.Resolve(name, "GenerationSpec")) - .Where(t => t != null) - .Select(t => (GenerationSpec)Activator.CreateInstance(t)) - .ToArray(); - - generatedFiles.AddRange(generator.Generate(generationSpecs)); - } - - foreach (string file in generatedFiles) - { - _logger.Log($"Generated {file}", LogLevel.Info); - } - - if (config.AddFilesToProject ?? TgConfig.DefaultAddFilesToProject) - { - AddFilesToProject(projectFolder, generatedFiles); - } - - // unregister assembly resolver - - _assemblyResolver.Unregister(); - - _logger.Log($"Files for project \"{projectFolder}\" generated successfully.{Environment.NewLine}", LogLevel.Info); - } - - private static void AddFilesToProject(string projectFolder, IEnumerable generatedFiles) - { - XmlDocument projectFile = _projectFileManager.ReadFromProjectFolder(projectFolder); - - foreach (string filePath in generatedFiles) - { - _projectFileManager.AddTsFile(projectFile, filePath); - } - - _projectFileManager.SaveProjectFile(projectFolder, projectFile); - } - - private static IEnumerable GetAssemblies(IEnumerable assemblyNames) - { - return assemblyNames.Select(Assembly.LoadFrom); - } + var services = new ServiceCollection(); + services.AddInterfacesWithSingleImplementation(); + services.AddTransient(); + services.AddTransient(); - private static void ShowHelp() - { - Console.WriteLine($"TypeGen v{ApplicationConfig.Version}" + Environment.NewLine + - Environment.NewLine + - "Usage: [dotnet-]typegen [options] [command]" + Environment.NewLine + - Environment.NewLine + - "Options:" + Environment.NewLine + - "-h|--help Show help information" + Environment.NewLine + - "-v|--verbose Show verbose output" + Environment.NewLine + - "-p|--project-folder Set project folder path(s)" + Environment.NewLine + - "-c|--config-path Set config path(s) to use" + Environment.NewLine + - Environment.NewLine + - "Commands:" + Environment.NewLine + - "generate Generate TypeScript files" + Environment.NewLine + - "getcwd Get current working directory" + Environment.NewLine + - Environment.NewLine + - "For more information, visit:" + Environment.NewLine + - "Documentation: https://typegen.readthedocs.io" + Environment.NewLine + - "GitHub: https://github.com/jburzynski/TypeGen"); - } + var serviceProvider = services.BuildServiceProvider(true); + return (int)await serviceProvider.GetService().Run(args); } -} +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/ProjectFileManagement/IProjectFileManager.cs b/src/TypeGen/TypeGen.Cli/ProjectFileManagement/IProjectFileManager.cs index 18e95ddc..db17ab98 100644 --- a/src/TypeGen/TypeGen.Cli/ProjectFileManagement/IProjectFileManager.cs +++ b/src/TypeGen/TypeGen.Cli/ProjectFileManagement/IProjectFileManager.cs @@ -1,12 +1,14 @@ -using System.Xml; +using System.Collections.Generic; +using System.Xml; namespace TypeGen.Cli.ProjectFileManagement { internal interface IProjectFileManager { - bool ContainsTsFile(XmlDocument projectFile, string filePath); + bool ContainsTsFile(XmlDocument projectDocument, string filePath); XmlDocument ReadFromProjectFolder(string projectFolder); void SaveProjectFile(string projectFolder, XmlDocument projectFile); - void AddTsFile(XmlDocument projectFile, string filePath); + void AddTsFile(XmlDocument projectDocument, string filePath); + void AddTsFiles(XmlDocument projectDocument, IEnumerable filePaths); } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/ProjectFileManagement/ProjectFileManager.cs b/src/TypeGen/TypeGen.Cli/ProjectFileManagement/ProjectFileManager.cs index 8aefd9af..1d8229d4 100644 --- a/src/TypeGen/TypeGen.Cli/ProjectFileManagement/ProjectFileManager.cs +++ b/src/TypeGen/TypeGen.Cli/ProjectFileManagement/ProjectFileManager.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System.Collections.Generic; +using System.Linq; using System.Xml; using TypeGen.Core.Storage; using TypeGen.Core.Validation; @@ -19,11 +20,11 @@ public ProjectFileManager(IFileSystem fileSystem) _fileSystem = fileSystem; } - public bool ContainsTsFile(XmlDocument projectFile, string filePath) + public bool ContainsTsFile(XmlDocument projectDocument, string filePath) { - Requires.NotNull(projectFile, nameof(projectFile)); + Requires.NotNull(projectDocument, nameof(projectDocument)); - XmlNodeList itemGroups = projectFile.DocumentElement?.SelectNodes($"{TypeScriptCompileXPath}[@Include='{filePath}']"); + XmlNodeList itemGroups = projectDocument.DocumentElement?.SelectNodes($"{TypeScriptCompileXPath}[@Include='{filePath}']"); return itemGroups != null && itemGroups.Count > 0; } @@ -51,22 +52,28 @@ private string GetProjectPath(string projectFolder) .FirstOrDefault(x => x.EndsWith(".csproj")); } - public void AddTsFile(XmlDocument projectFile, string filePath) + public void AddTsFiles(XmlDocument projectDocument, IEnumerable filePaths) { - Requires.NotNull(projectFile, nameof(projectFile)); + foreach (var filePath in filePaths) + AddTsFile(projectDocument, filePath); + } + + public void AddTsFile(XmlDocument projectDocument, string filePath) + { + Requires.NotNull(projectDocument, nameof(projectDocument)); - XmlElement documentElement = projectFile.DocumentElement; + XmlElement documentElement = projectDocument.DocumentElement; if (documentElement == null) throw new CliException("Project file has no XML document element"); - if (ContainsTsFile(projectFile, filePath)) return; + if (ContainsTsFile(projectDocument, filePath)) return; XmlNode itemGroupNode = documentElement .SelectSingleNode(TypeScriptCompileXPath) ?.ParentNode - ?? AddItemGroup(projectFile); + ?? AddItemGroup(projectDocument); itemGroupNode.AppendChild( - CreateItemGroupChild(projectFile, "TypeScriptCompile", filePath) + CreateItemGroupChild(projectDocument, "TypeScriptCompile", filePath) ); } diff --git a/src/TypeGen/TypeGen.Cli/TypeGen.Cli.csproj b/src/TypeGen/TypeGen.Cli/TypeGen.Cli.csproj index aae7cacf..1af81555 100644 --- a/src/TypeGen/TypeGen.Cli/TypeGen.Cli.csproj +++ b/src/TypeGen/TypeGen.Cli/TypeGen.Cli.csproj @@ -4,8 +4,12 @@ net7.0 4.5.0.0 4.5.0.0 + 4.5.0 + TypeGen + + diff --git a/src/TypeGen/TypeGen.Cli/TypeGenConfig/IGeneratorOptionsProvider.cs b/src/TypeGen/TypeGen.Cli/TypeGenConfig/IGeneratorOptionsProvider.cs deleted file mode 100644 index dbfc6ad8..00000000 --- a/src/TypeGen/TypeGen.Cli/TypeGenConfig/IGeneratorOptionsProvider.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections.Generic; -using System.Reflection; -using TypeGen.Core.Generator; - -namespace TypeGen.Cli.TypeGenConfig -{ - internal interface IGeneratorOptionsProvider - { - /// - /// Returns the GeneratorOptions object based on the passed ConfigParams - /// - /// - /// - /// - /// - GeneratorOptions GetGeneratorOptions(TgConfig config, IEnumerable assemblies, string projectFolder); - } -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/TypeResolution/AssemblyResolver.cs b/src/TypeGen/TypeGen.Cli/TypeResolution/AssemblyResolver.cs index ccae33bc..695200e8 100644 --- a/src/TypeGen/TypeGen.Cli/TypeResolution/AssemblyResolver.cs +++ b/src/TypeGen/TypeGen.Cli/TypeResolution/AssemblyResolver.cs @@ -11,27 +11,22 @@ namespace TypeGen.Cli.TypeResolution { - internal class AssemblyResolver : IAssemblyResolver + internal class AssemblyResolver : IDisposable { private readonly IFileSystem _fileSystem; private readonly ILogger _logger; private readonly string _projectFolder; - - private IEnumerable _directories; - public IEnumerable Directories - { - get => _directories; - set => _directories = value?.Select(d => Path.IsPathRooted((string)d) ? d : Path.Combine(_projectFolder, d)); - } + private readonly IEnumerable _directories; private readonly string _globalFallbackPath; private readonly string _sharedFolder; private List _nugetPackagesFolders; - public AssemblyResolver(IFileSystem fileSystem, ILogger logger, string projectFolder) + public AssemblyResolver(IFileSystem fileSystem, ILogger logger, string projectFolder, IEnumerable directories) { _fileSystem = fileSystem; _logger = logger; + _directories = directories; _projectFolder = projectFolder.ToAbsolutePath(_fileSystem); string dotnetInstallPath = GetDotnetInstallPath(); @@ -41,6 +36,7 @@ public AssemblyResolver(IFileSystem fileSystem, ILogger logger, string projectFo if (_fileSystem.DirectoryExists(dotNetInstallSharedPath)) _sharedFolder = dotNetInstallSharedPath; PopulateNuGetPackageFolders(); + Register(); } private void PopulateNuGetPackageFolders() @@ -53,12 +49,12 @@ private void PopulateNuGetPackageFolders() if (!_nugetPackagesFolders.Contains(_globalFallbackPath) && Directory.Exists(_globalFallbackPath)) _nugetPackagesFolders.Add(_globalFallbackPath); } - public void Register() + private void Register() { AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve; } - public void Unregister() + private void Unregister() { AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolve; } @@ -74,7 +70,7 @@ private Assembly AssemblyResolve(object sender, ResolveEventArgs args) if (assembly != null) return assembly; // user-defined - assembly = FindByPackageName(Directories, args.Name); + assembly = FindByPackageName(_directories, args.Name); if (assembly != null) return assembly; // step 2 - search recursively (shared + user-defined + nuget global + nuget fallback) @@ -90,14 +86,14 @@ private Assembly AssemblyResolve(object sender, ResolveEventArgs args) } // user-defined - assembly = FindRecursive(Directories, assemblyFileName, assemblyVersion); + assembly = FindRecursive(_directories, assemblyFileName, assemblyVersion); if (assembly != null) return assembly; // nuget assembly = FindRecursive(_nugetPackagesFolders, assemblyFileName, assemblyVersion); // log if assembly not found - List searchedDirectories = Directories.Concat(_nugetPackagesFolders).Concat(new[] {_sharedFolder}).ToList(); + List searchedDirectories = _directories.Concat(_nugetPackagesFolders).Concat(new[] {_sharedFolder}).ToList(); if (assembly == null) _logger.Log($"Could not resolve assembly: {args.Name} in any of the searched directories: {string.Join("; ", searchedDirectories)}", LogLevel.Error); // return assembly or null @@ -207,5 +203,17 @@ private string GetDotnetInstallPath() return @"C:\Program Files\dotnet"; // old behavior } + ~AssemblyResolver() => Dispose(false); + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose(bool disposing) + { + Unregister(); + } } } diff --git a/src/TypeGen/TypeGen.Cli/TypeResolution/ConverterResolver.cs b/src/TypeGen/TypeGen.Cli/TypeResolution/ConverterResolver.cs new file mode 100644 index 00000000..f37217c6 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/TypeResolution/ConverterResolver.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using TypeGen.Core.SpecGeneration; + +namespace TypeGen.Cli.TypeResolution; + +internal class ConverterResolver : IConverterResolver +{ + private readonly ITypeResolver _typeResolver; + + public ConverterResolver(ITypeResolver typeResolver) + { + _typeResolver = typeResolver; + } + + public IReadOnlyList Resolve(IEnumerable names) + { + return names + .Select(name => _typeResolver.Resolve(name, "Converter", new[] { typeof(T) })) + .Where(t => t != null) + .Select(t => (T)Activator.CreateInstance(t)) + .ToList(); + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/TypeResolution/GenerationSpecResolver.cs b/src/TypeGen/TypeGen.Cli/TypeResolution/GenerationSpecResolver.cs new file mode 100644 index 00000000..69738f7e --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/TypeResolution/GenerationSpecResolver.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using TypeGen.Core.SpecGeneration; + +namespace TypeGen.Cli.TypeResolution; + +internal class GenerationSpecResolver : IGenerationSpecResolver +{ + private readonly ITypeResolver _typeResolver; + + public GenerationSpecResolver(ITypeResolver typeResolver) + { + _typeResolver = typeResolver; + } + + public IReadOnlyList Resolve(IEnumerable names) + { + return names + .Select(name => _typeResolver.Resolve(name, "GenerationSpec")) + .Where(t => t != null) + .Select(t => (GenerationSpec)Activator.CreateInstance(t)) + .ToList(); + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/TypeResolution/IAssemblyResolver.cs b/src/TypeGen/TypeGen.Cli/TypeResolution/IAssemblyResolver.cs deleted file mode 100644 index abde2508..00000000 --- a/src/TypeGen/TypeGen.Cli/TypeResolution/IAssemblyResolver.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System.Collections.Generic; - -namespace TypeGen.Cli.TypeResolution -{ - internal interface IAssemblyResolver - { - IEnumerable Directories { get; set; } - void Register(); - void Unregister(); - } -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/TypeResolution/IConverterResolver.cs b/src/TypeGen/TypeGen.Cli/TypeResolution/IConverterResolver.cs new file mode 100644 index 00000000..97612062 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/TypeResolution/IConverterResolver.cs @@ -0,0 +1,8 @@ +using System.Collections.Generic; + +namespace TypeGen.Cli.TypeResolution; + +internal interface IConverterResolver +{ + IReadOnlyList Resolve(IEnumerable names); +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/TypeResolution/IGenerationSpecResolver.cs b/src/TypeGen/TypeGen.Cli/TypeResolution/IGenerationSpecResolver.cs new file mode 100644 index 00000000..4122317b --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/TypeResolution/IGenerationSpecResolver.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; +using TypeGen.Core.SpecGeneration; + +namespace TypeGen.Cli.TypeResolution; + +internal interface IGenerationSpecResolver +{ + IReadOnlyList Resolve(IEnumerable names); +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Ui/ActionResult.cs b/src/TypeGen/TypeGen.Cli/Ui/ActionResult.cs new file mode 100644 index 00000000..fad8a10a --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Ui/ActionResult.cs @@ -0,0 +1,13 @@ +namespace TypeGen.Cli.Ui; + +internal class ActionResult +{ + public bool IsSuccess { get; private set; } + + private ActionResult() + { + } + + public static ActionResult Success() => new() { IsSuccess = true }; + public static ActionResult Failure() => new() { IsSuccess = false }; +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Ui/ConsoleOutput.cs b/src/TypeGen/TypeGen.Cli/Ui/ConsoleOutput.cs new file mode 100644 index 00000000..62f24b40 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Ui/ConsoleOutput.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using TypeGen.Core.Storage; +using static TypeGen.Core.Utils.ConsoleUtils; + +namespace TypeGen.Cli.Ui; + +internal class ConsoleOutput : IConsoleOutput +{ + private readonly IFileSystem _fileSystem; + + public ConsoleOutput(IFileSystem fileSystem) + { + _fileSystem = fileSystem; + } + + public void ShowCwd() + { + var cwd = _fileSystem.GetCurrentDirectory(); + Console.WriteLine($"Current working directory is: {cwd}"); + } + + public void ShowGenerationBegin(string projectFolder) + { + Console.WriteLine($"Generating files for project \"{projectFolder}\"..."); + } + + public void ShowGeneratedFiles(List generatedFiles) + { + foreach (var file in generatedFiles) + Console.WriteLine($"Generated {file}"); + } + + public void ShowGenerationEnd(string projectFolder) + { + Console.WriteLine($"Files for project \"{projectFolder}\" generated successfully.{Environment.NewLine}"); + } + + public void ShowErrors(IEnumerable messages) + { + WithColor(ConsoleColor.Red, () => + { + foreach (var message in messages) Console.WriteLine(message); + }); + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Ui/IConsoleOutput.cs b/src/TypeGen/TypeGen.Cli/Ui/IConsoleOutput.cs new file mode 100644 index 00000000..341ce3b3 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Ui/IConsoleOutput.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace TypeGen.Cli.Ui; + +internal interface IConsoleOutput +{ + void ShowCwd(); + void ShowGenerationBegin(string projectFolder); + void ShowGeneratedFiles(List generatedFiles); + void ShowGenerationEnd(string projectFolder); + void ShowErrors(IEnumerable messages); +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Ui/IPresenter.cs b/src/TypeGen/TypeGen.Cli/Ui/IPresenter.cs new file mode 100644 index 00000000..ce98b34d --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Ui/IPresenter.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace TypeGen.Cli.Ui; + +internal interface IPresenter +{ + ActionResult GetCwd(); + ActionResult Generate(bool verbose, IReadOnlyCollection projectFolderPaths, IReadOnlyCollection configPaths, string outputFolder); +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Ui/Presenter.cs b/src/TypeGen/TypeGen.Cli/Ui/Presenter.cs new file mode 100644 index 00000000..98612f70 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Ui/Presenter.cs @@ -0,0 +1,133 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Mail; +using System.Reflection; +using System.Threading.Tasks; +using TypeGen.Cli.Build; +using TypeGen.Cli.GenerationConfig; +using TypeGen.Cli.ProjectFileManagement; +using TypeGen.Cli.TypeResolution; +using TypeGen.Cli.Ui.Validation; +using TypeGen.Core.Extensions; +using TypeGen.Core.Generator; +using TypeGen.Core.Logging; +using TypeGen.Core.Storage; + +namespace TypeGen.Cli.Ui; + +internal class Presenter : IPresenter +{ + private readonly ILogger _logger; + private readonly IConsoleOutput _consoleOutput; + private readonly IFileSystem _fileSystem; + private readonly IConfigProvider _configProvider; + private readonly IProjectBuild _projectBuild; + private readonly IProjectFileManager _projectFileManager; + + private readonly IGenerateValidator _generateValidator; + + public Presenter( + IConsoleOutput consoleOutput, + IFileSystem fileSystem, + ILogger logger, + IConfigProvider configProvider, + IProjectBuild projectBuild, + IProjectFileManager projectFileManager, + IGenerateValidator generateValidator) + { + _consoleOutput = consoleOutput; + _fileSystem = fileSystem; + _logger = logger; + _configProvider = configProvider; + _projectBuild = projectBuild; + _projectFileManager = projectFileManager; + _generateValidator = generateValidator; + } + + public ActionResult GetCwd() + { + _consoleOutput.ShowCwd(); + return ActionResult.Success(); + } + + public ActionResult Generate(bool verbose, IReadOnlyCollection projectFolderPaths, IReadOnlyCollection configPaths, string outputFolder) + { + if (projectFolderPaths.IsNullOrEmpty()) projectFolderPaths = new[] { "." }; + var validationResult = _generateValidator.Validate(verbose, projectFolderPaths, configPaths, outputFolder); + + validationResult + .Match( + () => GeneratePrivate(verbose, projectFolderPaths, configPaths, outputFolder), + messages => _consoleOutput.ShowErrors(messages) + ); + + return validationResult.IsSuccess ? ActionResult.Success() : ActionResult.Failure(); + } + + private void GeneratePrivate(bool verbose, IReadOnlyCollection projectFolderPaths, IReadOnlyCollection configPaths, string outputFolder) + { + SetLoggerVerbosity(verbose); + + if (configPaths.None()) configPaths = Enumerable.Repeat((string)null, projectFolderPaths.Count).ToList(); + var projectConfigPairs = projectFolderPaths + .Zip(configPaths) + .Select(x => (projectFolderPath: x.First, configPath: x.Second)); + + foreach (var pair in projectConfigPairs) + GenerateSingle(pair.projectFolderPath, pair.configPath, outputFolder); + } + + private void GenerateSingle(string projectFolder, string configPath, string outputFolder) + { + // prep + + var configConsoleOptions = new ConfigConsoleOptions(outputFolder); + var config = _configProvider.GetConfig(configPath, projectFolder, configConsoleOptions); + var assemblies = config.GetAssemblies().Select(Assembly.LoadFrom).ToList(); + + using var assemblyResolver = new AssemblyResolver(_fileSystem, _logger, projectFolder, config.ExternalAssemblyPaths); + var typeResolver = new TypeResolver(_logger, _fileSystem, projectFolder, assemblies); + var converterResolver = new ConverterResolver(typeResolver); + var generationSpecResolver = new GenerationSpecResolver(typeResolver); + + var generatorOptionsProvider = new GeneratorOptionsProvider(converterResolver); + var generatorOptions = generatorOptionsProvider.GetGeneratorOptions(config, assemblies, projectFolder); + var generator = new Generator(generatorOptions, _logger); + + // generate + + if (config.ClearOutputDirectory == true) _fileSystem.ClearDirectory(generatorOptions.BaseOutputDirectory); + if (config.BuildProject == true) _projectBuild.Build(projectFolder); + + _consoleOutput.ShowGenerationBegin(projectFolder); + + var generatedFiles = new List(); + + if (config.GenerationSpecs.None() || config.GenerateFromAssemblies == true) + generatedFiles.AddRange(generator.Generate(assemblies)); + + if (config.GenerationSpecs.Any()) + { + var generationSpecs = generationSpecResolver.Resolve(config.GenerationSpecs); + generatedFiles.AddRange(generator.Generate(generationSpecs)); + } + + if (config.AddFilesToProject == true) AddFilesToProject(projectFolder, generatedFiles); + + _consoleOutput.ShowGeneratedFiles(generatedFiles); + _consoleOutput.ShowGenerationEnd(projectFolder); + } + + private void AddFilesToProject(string projectFolder, IEnumerable generatedFiles) + { + var projectDocument = _projectFileManager.ReadFromProjectFolder(projectFolder); + _projectFileManager.AddTsFiles(projectDocument, generatedFiles); + _projectFileManager.SaveProjectFile(projectFolder, projectDocument); + } + + private void SetLoggerVerbosity(bool verbose) + { + _logger.MinLevel = verbose ? LogLevel.Debug : LogLevel.Info; + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Ui/Validation/GenerateValidator.cs b/src/TypeGen/TypeGen.Cli/Ui/Validation/GenerateValidator.cs new file mode 100644 index 00000000..4a456472 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Ui/Validation/GenerateValidator.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using System.Linq; +using TypeGen.Core.Extensions; + +namespace TypeGen.Cli.Ui.Validation; + +internal class GenerateValidator : IGenerateValidator +{ + public ValidationResult Validate(bool verbose, IReadOnlyCollection projectFolderPaths, IReadOnlyCollection configPaths, string outputFolder) + { + var messages = new List(); + + if (configPaths.IsNotNullAndNotEmpty()) + { + if (projectFolderPaths.Count != configPaths.Count) + messages.Add("The number of project folders and config paths must be the same."); + } + + return new ValidationResult(messages); + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Ui/Validation/IGenerateValidator.cs b/src/TypeGen/TypeGen.Cli/Ui/Validation/IGenerateValidator.cs new file mode 100644 index 00000000..061d4283 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Ui/Validation/IGenerateValidator.cs @@ -0,0 +1,8 @@ +using System.Collections.Generic; + +namespace TypeGen.Cli.Ui.Validation; + +internal interface IGenerateValidator +{ + ValidationResult Validate(bool verbose, IReadOnlyCollection projectFolderPaths, IReadOnlyCollection configPaths, string outputFolder); +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Cli/Ui/Validation/ValidationResult.cs b/src/TypeGen/TypeGen.Cli/Ui/Validation/ValidationResult.cs new file mode 100644 index 00000000..c05f8876 --- /dev/null +++ b/src/TypeGen/TypeGen.Cli/Ui/Validation/ValidationResult.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using TypeGen.Core.Extensions; + +namespace TypeGen.Cli.Ui.Validation; + +internal class ValidationResult +{ + public bool IsSuccess { get; } + public IReadOnlyCollection Messages { get; } + + public ValidationResult(IEnumerable messages) + { + var messagesList = messages.ToList(); + + if (messagesList.IsNullOrEmpty()) + { + IsSuccess = true; + Messages = Array.Empty(); + } + else + { + IsSuccess = false; + Messages = messagesList.ToList(); + } + } + + public void Match(Action onSuccess, Action> onFailure) + { + if (IsSuccess) + onSuccess(); + else + onFailure(Messages); + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/Extensions/EnumerableExtensions.cs b/src/TypeGen/TypeGen.Core/Extensions/EnumerableExtensions.cs index 716c4c61..e9b11923 100644 --- a/src/TypeGen/TypeGen.Core/Extensions/EnumerableExtensions.cs +++ b/src/TypeGen/TypeGen.Core/Extensions/EnumerableExtensions.cs @@ -60,6 +60,15 @@ public static bool IsNullOrEmpty(this IEnumerable enumerable) return !enumerable.Any(); } + /// + /// Checks if an enumerable is not null and not empty + /// + /// + /// + /// + public static bool IsNotNullAndNotEmpty(this IEnumerable enumerable) + => !enumerable.IsNullOrEmpty(); + /// /// Checks if the is empty. /// diff --git a/src/TypeGen/TypeGen.Core/Logging/ConsoleLogger.cs b/src/TypeGen/TypeGen.Core/Logging/ConsoleLogger.cs index b4e758ff..d8d7df0a 100644 --- a/src/TypeGen/TypeGen.Core/Logging/ConsoleLogger.cs +++ b/src/TypeGen/TypeGen.Core/Logging/ConsoleLogger.cs @@ -1,5 +1,6 @@ using System; using TypeGen.Core.Validation; +using static TypeGen.Core.Utils.ConsoleUtils; namespace TypeGen.Core.Logging { @@ -8,11 +9,11 @@ namespace TypeGen.Core.Logging /// public class ConsoleLogger : ILogger { - private readonly bool _verbose; + public LogLevel MinLevel { get; set; } - public ConsoleLogger(bool verbose) + public ConsoleLogger(LogLevel minLevel = LogLevel.Info) { - _verbose = verbose; + MinLevel = minLevel; } /// @@ -24,26 +25,16 @@ public void Log(string message, LogLevel level) { Requires.NotNullOrEmpty(message, nameof(message)); - LogLevel minLevel = _verbose ? LogLevel.Debug : LogLevel.Info; + if (level < MinLevel) return; - if (level < minLevel) return; - - ConsoleColor oldColor = Console.ForegroundColor; - - switch (level) + var color = level switch { - case LogLevel.Warning: - message = "WARNING: " + message; - Console.ForegroundColor = ConsoleColor.Yellow; - break; - case LogLevel.Error: - Console.ForegroundColor = ConsoleColor.Red; - break; - } + LogLevel.Warning => ConsoleColor.Yellow, + LogLevel.Error => ConsoleColor.Red, + _ => Console.ForegroundColor + }; - Console.WriteLine(message); - - Console.ForegroundColor = oldColor; + WithColor(color, () => Console.WriteLine(message)); } } } diff --git a/src/TypeGen/TypeGen.Core/Logging/ILogger.cs b/src/TypeGen/TypeGen.Core/Logging/ILogger.cs index f2e55b47..c20c48c0 100644 --- a/src/TypeGen/TypeGen.Core/Logging/ILogger.cs +++ b/src/TypeGen/TypeGen.Core/Logging/ILogger.cs @@ -2,6 +2,7 @@ { public interface ILogger { + LogLevel MinLevel { get; set; } void Log(string message, LogLevel level); } } \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/Utils/ConsoleUtils.cs b/src/TypeGen/TypeGen.Core/Utils/ConsoleUtils.cs new file mode 100644 index 00000000..e4fc4342 --- /dev/null +++ b/src/TypeGen/TypeGen.Core/Utils/ConsoleUtils.cs @@ -0,0 +1,14 @@ +using System; + +namespace TypeGen.Core.Utils; + +internal class ConsoleUtils +{ + public static void WithColor(ConsoleColor color, Action action) + { + var oldColor = Console.ForegroundColor; + Console.ForegroundColor = color; + action(); + Console.ForegroundColor = oldColor; + } +} \ No newline at end of file diff --git a/update-version.ps1 b/update-version.ps1 index 1920c98b..2cf8db11 100644 --- a/update-version.ps1 +++ b/update-version.ps1 @@ -27,38 +27,55 @@ $assemblyNewVersion = "$($newVersionMajor).$($newVersionMinor).0.0" $nuspecPath = "nuget\TypeGen.nuspec" if (Test-Path $nuspecPath) { - (Get-Content $nuspecPath).Replace("$($oldVersion)", "$($newVersion)") | Set-Content $nuspecPath + (Get-Content $nuspecPath) ` + -Replace "$($oldVersion)", "$($newVersion)" ` + | Set-Content $nuspecPath } $dotNetCliNuspecPath = "nuget-dotnetcli\dotnet-typegen.nuspec" if (Test-Path $dotNetCliNuspecPath) { - (Get-Content $dotNetCliNuspecPath).Replace("$($oldVersion)", "$($newVersion)") | Set-Content $dotNetCliNuspecPath - #.Replace("id=""TypeGen"" version=""$($oldVersion)""", "id=""TypeGen"" version=""$($newVersion)""") + (Get-Content $dotNetCliNuspecPath) ` + -Replace "$($oldVersion)", "$($newVersion)" ` + | Set-Content $dotNetCliNuspecPath } -#$docsConfPath = "..\TypeGenDocs\source\conf.py" -#if (Test-Path $docsConfPath) { -# (Get-Content $docsConfPath).Replace("version = u'$($oldVersion)'", "version = u'$($newVersion)'") | Set-Content $docsConfPath -#} - $appConfigPath = "src\TypeGen\TypeGen.Cli\ApplicationConfig.cs" if (Test-Path $appConfigPath) { - (Get-Content $appConfigPath).Replace("Version => ""$($oldVersion)""", "Version => ""$($newVersion)""") | Set-Content $appConfigPath + (Get-Content $appConfigPath) ` + -Replace "Version => ""$($oldVersion)""", "Version => ""$($newVersion)""" ` + | Set-Content $appConfigPath } $nugetUpdatePath = "nuget-update.ps1" if (Test-Path $nugetUpdatePath) { - (Get-Content $nugetUpdatePath).Replace("TypeGen.$($oldVersion)", "TypeGen.$($newVersion)").Replace("dotnet-typegen.$($oldVersion)", "dotnet-typegen.$($newVersion)") | Set-Content $nugetUpdatePath + (Get-Content $nugetUpdatePath) ` + -Replace "TypeGen.$($oldVersion)", "TypeGen.$($newVersion)" ` + -Replace "dotnet-typegen.$($oldVersion)", "dotnet-typegen.$($newVersion)" ` + | Set-Content $nugetUpdatePath +} + +$applicationConfigPath = "src\TypeGen\TypeGen.Cli\ApplicationConfig.cs" +if (Test-Path $applicationConfigPath) { + (Get-Content $applicationConfigPath) ` + -Replace "Version = ""$($oldVersion)""", "Version = ""$($newVersion)""" ` + | Set-Content $applicationConfigPath } $typeGenCliCsprojPath = "src\TypeGen\TypeGen.Cli\TypeGen.Cli.csproj" if (Test-Path $typeGenCliCsprojPath) { - (Get-Content $typeGenCliCsprojPath).Replace("$($assemblyOldVersion)", "$($assemblyNewVersion)").Replace("$($assemblyOldVersion)", "$($assemblyNewVersion)") | Set-Content $typeGenCliCsprojPath + (Get-Content $typeGenCliCsprojPath) ` + -Replace "$($assemblyOldVersion)", "$($assemblyNewVersion)" ` + -Replace "$($assemblyOldVersion)", "$($assemblyNewVersion)" ` + -Replace "$($oldVersion)", "$($newVersion)" ` + | Set-Content $typeGenCliCsprojPath } $typeGenCoreCsprojPath = "src\TypeGen\TypeGen.Core\TypeGen.Core.csproj" if (Test-Path $typeGenCoreCsprojPath) { - (Get-Content $typeGenCoreCsprojPath).Replace("$($assemblyOldVersion)", "$($assemblyNewVersion)").Replace("$($assemblyOldVersion)", "$($assemblyNewVersion)") | Set-Content $typeGenCoreCsprojPath + (Get-Content $typeGenCoreCsprojPath) ` + -Replace "$($assemblyOldVersion)", "$($assemblyNewVersion)" ` + -Replace "$($assemblyOldVersion)", "$($assemblyNewVersion)" ` + | Set-Content $typeGenCoreCsprojPath } # remove old NuGet package From d28c8afff75c8a1cdb89cca7524a0c0e811d0a35 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Fri, 1 Sep 2023 15:03:17 +0200 Subject: [PATCH 13/16] added test for TS interface inheritance when TS interfaces are CS classes --- .../TsInterfaceInheritance/Entities/Base.cs | 6 ++++ .../TsInterfaceInheritance/Entities/Sub.cs | 6 ++++ .../TsInterfaceInheritance/Expected/sub.ts | 9 ++++++ .../TsInterfaceInheritanceTest.cs | 31 +++++++++++++++++++ .../TypeGen.IntegrationTest.csproj | 1 + 5 files changed, 53 insertions(+) create mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Base.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Sub.cs create mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Expected/sub.ts create mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Base.cs b/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Base.cs new file mode 100644 index 00000000..5ca815e1 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Base.cs @@ -0,0 +1,6 @@ +namespace TypeGen.IntegrationTest.TsInterfaceInheritance.Entities; + +public class Base +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Sub.cs b/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Sub.cs new file mode 100644 index 00000000..046a5803 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Sub.cs @@ -0,0 +1,6 @@ +namespace TypeGen.IntegrationTest.TsInterfaceInheritance.Entities; + +public class Sub : Base +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Expected/sub.ts b/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Expected/sub.ts new file mode 100644 index 00000000..e5eb8448 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Expected/sub.ts @@ -0,0 +1,9 @@ +/** + * This is a TypeGen auto-generated file. + * Any changes made to this file can be lost when this file is regenerated. + */ + +import { Base } from "./base"; + +export interface Sub extends Base { +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs b/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs new file mode 100644 index 00000000..e6d33d34 --- /dev/null +++ b/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs @@ -0,0 +1,31 @@ +using System.Threading.Tasks; +using TypeGen.Core.Generator; +using TypeGen.Core.SpecGeneration; +using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.IntegrationTest.TsInterfaceInheritance.Entities; +using Xunit; + +namespace TypeGen.IntegrationTest.TsInterfaceInheritance; + +public class TsInterfaceInheritanceTest : GenerationTestBase +{ + [Fact] + public async Task cs_classes_which_are_ts_interfaces_should_respect_ts_interface_inheritance() + { + var type = typeof(Sub); + const string expectedLocation = "TypeGen.IntegrationTest.TsInterfaceInheritance.Expected.sub.ts"; + var generationSpec = new TsInterfaceInheritanceGenerationSpec(); + var generatorOptions = new GeneratorOptions(); + + await TestGenerationSpec(type, expectedLocation, generationSpec, generatorOptions); + } + + private class TsInterfaceInheritanceGenerationSpec : GenerationSpec + { + public TsInterfaceInheritanceGenerationSpec() + { + AddInterface(); + AddInterface(); + } + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj b/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj index f8d272ee..f7e07b58 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj +++ b/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj @@ -113,6 +113,7 @@ + From b233f176d7edf7df376f7a8913e316ea967cd96f Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Mon, 4 Sep 2023 14:53:03 +0200 Subject: [PATCH 14/16] - added test for the correct order of Generator's callbacks calls (OnBeforeGeneration etc.) - added params[] to Generator.Generate and Generator.GenerateAsync - renamed the project TypeGen.IntegrationTest to TypeGen.FileContentTest --- .gitignore | 2 + appveyor.yml | 2 +- .../CliSmokeTest.cs | 4 +- src/TypeGen/TypeGen.Cli/AssemblyInfo.cs | 2 +- .../ExceptionShouldContainInitialType.cs | 8 +- .../Generator/GeneratorTest.cs | 71 ++++++++++++ src/TypeGen/TypeGen.Core/AssemblyInfo.cs | 2 +- .../TypeGen.Core/Generator/Generator.cs | 20 ++++ .../SpecGeneration/GenerationSpec.cs | 13 +++ .../Blacklist/BlacklistTest.cs | 14 +-- .../Blacklist/Entities/Bar.cs | 6 + .../Blacklist/Entities/Baz.cs | 6 + .../Entities/ClassWithBlacklistedBase.cs | 2 +- .../Entities/ClassWithBlacklistedInterface.cs | 2 +- .../ClassWithBlacklistedPropertyType.cs | 2 +- .../ClassWithBlacklistedTypeInArray.cs | 3 +- ...ClassWithBlacklistedTypeInCustomGeneric.cs | 2 +- .../ClassWithBlacklistedTypeInDictionary.cs | 2 +- .../Blacklist/Entities/CustomGeneric.cs | 6 + .../Blacklist/Entities/IFoo.cs | 6 + .../Entities/InterfaceWithBlacklistedBase.cs | 2 +- .../InterfaceWithBlacklistedPropertyType.cs | 2 +- .../Blacklist/Entities/MyRecord.cs | 3 + .../Expected/class-with-blacklisted-base.ts | 0 .../class-with-blacklisted-interface.ts | 0 .../interface-with-blacklisted-base.ts | 0 .../Blacklist/Expected/my-record.ts | 0 .../CircularGenericConstraintTest.cs | 19 ++-- .../Entities/TestClasses.cs | 2 +- .../Expected/ICicrularConstraintInterface.ts | 0 .../Expected/IMultipleConstraintInterface.ts | 0 .../Expected/IRecursiveConstraintInterface.ts | 0 ...eConstraintInterfaceWithClassConstraint.ts | 0 ...ConstraintInterfaceWithStructConstraint.ts | 0 .../Expected/RecursiveConstraintClass.ts | 0 .../Comments/CommentsTest.cs | 26 ++--- .../Comments/Entities/ITsInterface.cs | 2 +- .../Comments/Entities/TsClass.cs | 2 +- .../Comments/Entities/TsEnum.cs | 2 +- .../Comments/Entities/TsEnumUnion.cs | 2 +- .../Comments/Entities/TsGeneric.cs | 2 +- .../Expected/i-ts-interface-default-export.ts | 0 .../Comments/Expected/i-ts-interface.ts | 0 .../Expected/ts-class-default-export.ts | 2 +- .../Comments/Expected/ts-class.ts | 2 +- .../Expected/ts-enum-default-export.ts | 0 .../Expected/ts-enum-union-default-export.ts | 0 .../Comments/Expected/ts-enum-union.ts | 0 .../Comments/Expected/ts-enum.ts | 0 .../Expected/ts-generic-default-export.ts | 0 .../Comments/Expected/ts-generic.ts | 0 .../CommonCases/CommonCasesGenerationTest.cs | 103 +++++++++++++++++ .../CommonCases/Entities/ArrayOfNullable.cs | 2 +- .../CommonCases/Entities/BaseClass.cs | 2 +- .../CommonCases/Entities/BaseClass2.cs | 2 +- .../CommonCases/Entities/CircularRefClass1.cs | 2 +- .../CommonCases/Entities/CircularRefClass2.cs | 2 +- .../Entities/Constants/FooConstants.cs | 2 +- .../Constants/Structs/FooConstants.cs | 2 +- .../CommonCases/Entities/CustomBaseClass.cs | 2 +- .../Entities/CustomBaseCustomImport.cs | 2 +- .../Entities/CustomEmptyBaseClass.cs | 2 +- .../ClassWithUri.cs | 2 +- .../Entities/DefaultMemberComplexValues.cs | 2 +- .../Entities/DefaultMemberValues.cs | 2 +- .../DictionaryStringObjectErrorCase.cs | 2 +- .../Entities/DictionaryWithEnumKey.cs | 2 +- .../CommonCases/Entities/EnumAsUnionType.cs | 2 +- .../CommonCases/Entities/EnumShortValues.cs | 2 +- .../Entities/EnumWithCustomHeadAndBody.cs | 2 +- .../CommonCases/Entities/ErrorCase/Bar.cs | 2 +- .../CommonCases/Entities/ErrorCase/C.cs | 2 +- .../CommonCases/Entities/ErrorCase/D.cs | 2 +- .../CommonCases/Entities/ErrorCase/EClass.cs | 2 +- .../CommonCases/Entities/ErrorCase/FClass.cs | 2 +- .../CommonCases/Entities/ErrorCase/Foo.cs | 2 +- .../CommonCases/Entities/ErrorCase/FooType.cs | 2 +- .../Entities/ExtendedPrimitivesClass.cs | 2 +- .../CommonCases/Entities/ExternalDepsClass.cs | 2 +- .../CommonCases/Entities/GenericBaseClass.cs | 2 +- .../CommonCases/Entities/GenericClass.cs | 2 +- .../Entities/GenericWithRestrictions.cs | 2 +- .../CommonCases/Entities/ITestInterface.cs | 2 +- .../Entities/JsonProperty/JsonPropertyTest.cs | 2 +- .../CommonCases/Entities/LiteDbEntity.cs | 2 +- .../CommonCases/Entities/NestedEntity.cs | 2 +- .../CommonCases/Entities/NoSlashOutputDir.cs | 2 +- .../Entities/NotGeneratedBaseClass.cs | 6 + .../CommonCases/Entities/ReadonlyInterface.cs | 2 +- .../CommonCases/Entities/StandaloneEnum.cs | 2 +- .../CommonCases/Entities/StaticReadonly.cs | 2 +- .../CommonCases/Entities/StrictNullsClass.cs | 2 +- .../CommonCases/Entities/Structs/BaseClass.cs | 2 +- .../Entities/Structs/CustomBaseClass.cs | 2 +- .../Structs/CustomBaseCustomImport.cs | 2 +- .../Entities/Structs/CustomEmptyBaseClass.cs | 2 +- .../Structs/DefaultMemberComplexValues.cs | 2 +- .../Entities/Structs/DefaultMemberValues.cs | 2 +- .../Structs/ExtendedPrimitivesClass.cs | 2 +- .../Entities/Structs/ExternalDepsClass.cs | 2 +- .../Entities/Structs/GenericBaseClass.cs | 2 +- .../Structs/GenericWithRestrictions.cs | 2 +- .../CommonCases/Entities/Structs/IBar.cs | 6 + .../CommonCases/Entities/Structs/IFoo.cs | 6 + .../Entities/Structs/ITestInterface.cs | 2 +- .../Entities/Structs/LiteDbEntity.cs | 2 +- .../Entities/Structs/NoSlashOutputDir.cs | 2 +- .../Entities/Structs/ReadonlyInterface.cs | 2 +- .../Entities/Structs/StaticReadonly.cs | 2 +- .../Entities/Structs/StrictNullsClass.cs | 2 +- .../Entities/Structs/TestInterface.cs | 2 +- .../Entities/Structs/TypeUnions.cs | 2 +- .../CommonCases/Entities/TestClass.cs | 2 +- .../CommonCases/Entities/TestEnum.cs | 2 +- .../CommonCases/Entities/TestInterface.cs | 2 +- .../CommonCases/Entities/TypeUnions.cs | 2 +- .../WithGenericBaseClassCustomType.cs | 2 +- .../CommonCases/Entities/WithIgnoredBase.cs | 2 +- .../Entities/WithIgnoredBaseAndCustomBase.cs | 2 +- .../CommonCases/Expected/array-of-nullable.ts | 0 .../CommonCases/Expected/bar.ts | 0 .../CommonCases/Expected/base-class.ts | 0 .../CommonCases/Expected/base-class2.ts | 0 .../CommonCases/Expected/c.ts | 0 .../CommonCases/Expected/custom-base-class.ts | 0 .../Expected/custom-base-custom-import.ts | 0 .../Expected/custom-empty-base-class.ts | 0 .../CommonCases/Expected/d.ts | 0 .../Expected/default-member-values.ts | 0 .../Expected/default-member-values_struct.ts | 0 .../dictionary-string-object-error-case.ts | 0 .../Expected/dictionary-with-enum-key.ts | 0 .../CommonCases/Expected/e-class.ts | 0 .../Expected/enum-as-union-type.ts | 0 .../CommonCases/Expected/enum-short-values.ts | 0 .../Expected/extended-primitives-class.ts | 0 .../Expected/external-deps-class.ts | 0 .../CommonCases/Expected/f-class.ts | 0 .../CommonCases/Expected/foo-constants.ts | 0 .../CommonCases/Expected/foo-type.ts | 0 .../CommonCases/Expected/foo.ts | 0 .../Expected/generic-base-class.ts | 0 .../CommonCases/Expected/generic-class.ts | 0 .../Expected/generic-with-restrictions.ts | 0 .../CommonCases/Expected/i-test-interface.ts | 0 .../CommonCases/Expected/index.ts | 0 .../CommonCases/Expected/lite-db-entity.ts | 0 .../slash/output/dir/no-slash-output-dir.ts | 0 .../Expected/readonly-interface.ts | 0 .../CommonCases/Expected/standalone-enum.ts | 0 .../CommonCases/Expected/static-readonly.ts | 0 .../Expected/strict-nulls-class.ts | 0 .../Expected/test-classes/base-class.ts | 0 .../Expected/test-classes/base-class2.ts | 0 .../test-classes/circular-ref-class1.ts | 0 .../test-classes/circular-ref-class2.ts | 0 .../Expected/test-classes/test-class.ts | 0 .../Expected/test-enums/test-enum.ts | 0 .../test-interfaces/test-interface.ts | 0 .../CommonCases/Expected/type-unions.ts | 0 .../very/nested/directory/nested-entity.ts | 0 .../with-generic-base-class-custom-type.ts | 0 .../with-ignored-base-and-custom-base.ts | 0 .../CommonCases/Expected/with-ignored-base.ts | 0 .../ConstantsOnly/ConstantsOnlyTest.cs | 6 +- .../ConstantsOnly/Entities/ConstantsOnly.cs | 2 +- .../ConstantsOnly/Expected/constants-only.ts | 0 .../Converters/JsonMemberNameConverter.cs | 2 +- .../PascalCaseToCamelCaseJsonConverter.cs | 2 +- .../CustomBaseInterfacesTest.cs | 10 +- .../CustomBaseInterfaces/Entities/Foo.cs | 2 +- .../CustomBaseInterfaces/Entities/ITest.cs | 6 + .../CustomBaseInterfaces/Expected/foo.ts | 0 .../CustomMappingsClassGeneration.cs | 9 +- .../Expected/class-with-uri.ts | 0 .../DefaultExport/DefaultExportTest.cs | 27 +++-- .../Entities/ClassWithDefaultExport.cs | 2 +- .../Entities/ClassWithImports.cs | 2 +- .../Entities/ClassWithoutDefaultExport.cs | 2 +- .../Entities/GenericClassWithDefaultExport.cs | 2 +- .../Entities/InterfaceWithDefaultExport.cs | 2 +- .../Structs/ClassWithDefaultExport.cs | 2 +- .../Entities/Structs/ClassWithImports.cs | 2 +- .../Structs/ClassWithoutDefaultExport.cs | 2 +- .../Structs/GenericClassWithDefaultExport.cs | 2 +- .../Structs/InterfaceWithDefaultExport.cs | 2 +- .../Expected/class-with-default-export.ts | 0 .../Expected/class-with-imports.ts | 0 .../Expected/class-without-default-export.ts | 0 .../generic-class-with-default-export.ts | 0 .../Expected/interface-with-default-export.ts | 0 .../Entities/Child.cs | 6 + .../Entities/Parent.cs | 2 +- .../Expected/child-as-class.ts | 0 .../Expected/child-as-interface.ts | 0 .../ExportTypesAsInterfacesByDefaultTest.cs | 10 +- .../Extensions/StringExtensions.cs | 2 +- .../GenerationSpecsForStructsTest.cs | 18 +-- .../IgnoreBaseInterfaces/Entities/ITest.cs | 6 + .../IgnoreBaseInterfaces/Entities/Test.cs | 2 +- .../IgnoreBaseInterfaces/Expected/test.ts | 0 .../IgnoreBaseInterfacesTest.cs | 8 +- .../ImportType/Entities/DepClass.cs | 6 + .../ImportType/Entities/TsClass.cs | 2 +- .../Expected/ts-class-default-export.ts | 0 .../ImportType/Expected/ts-class.ts | 0 .../ImportType/ImportTypeTest.cs | 11 +- .../Entities/NullableClass.cs | 2 +- .../Expected/nullable-class.ts | 0 .../NullableTranslationTest.cs | 8 +- .../Entities/ImplementsInterfaces.cs | 10 ++ .../Expected/implements-interfaces.ts | 0 .../StructImplementsInterfacesTest.cs | 14 +-- .../TestingUtils/EmbededResourceReader.cs | 5 +- .../TestingUtils/GeneratedOutput.cs | 2 +- .../TestingUtils/GenerationTestBase.cs | 5 +- .../GeneratorOutputInterceptor.cs | 2 +- .../Entities/TsClass.cs | 5 + .../Entities/TsInterface.cs | 6 + .../Expected/ts-class.ts | 0 .../TsClassExtendsTsInterfaceTest.cs | 8 +- .../TsInterfaceInheritance/Entities/Base.cs | 6 + .../TsInterfaceInheritance/Entities/Sub.cs | 6 + .../TsInterfaceInheritance/Expected/sub.ts | 0 .../TsInterfaceInheritanceTest.cs | 8 +- .../TypeGen.FileContentTest.csproj} | 4 +- .../Entities/IId.cs | 2 +- .../Entities/IIdentifier.cs | 2 +- .../Entities/ProductDto.cs | 2 +- .../Expected/product-dto.ts | 0 ...ultExportBreaksInterfaceInheritanceTest.cs | 8 +- .../tgconfig.json | 0 .../Blacklist/Entities/Bar.cs | 6 - .../Blacklist/Entities/Baz.cs | 6 - .../Blacklist/Entities/CustomGeneric.cs | 6 - .../Blacklist/Entities/IFoo.cs | 6 - .../Blacklist/Entities/MyRecord.cs | 3 - .../CommonCases/CommonCasesGenerationTest.cs | 107 ------------------ .../Entities/NotGeneratedBaseClass.cs | 6 - .../CommonCases/Entities/Structs/IBar.cs | 6 - .../CommonCases/Entities/Structs/IFoo.cs | 6 - .../CustomBaseInterfaces/Entities/ITest.cs | 6 - .../Entities/Child.cs | 6 - .../IgnoreBaseInterfaces/Entities/ITest.cs | 6 - .../ImportType/Entities/DepClass.cs | 6 - .../Entities/ImplementsInterfaces.cs | 10 -- .../Entities/TsClass.cs | 5 - .../Entities/TsInterface.cs | 6 - .../TsInterfaceInheritance/Entities/Base.cs | 6 - .../TsInterfaceInheritance/Entities/Sub.cs | 6 - src/TypeGen/TypeGen.sln | 2 +- 251 files changed, 528 insertions(+), 439 deletions(-) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.Cli.Test}/CliSmokeTest.cs (97%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.Core.Test/Generator}/ExceptionShouldContainInitialType.cs (85%) create mode 100644 src/TypeGen/TypeGen.Core.Test/Generator/GeneratorTest.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/BlacklistTest.cs (94%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/Bar.cs create mode 100644 src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/Baz.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Entities/ClassWithBlacklistedBase.cs (67%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Entities/ClassWithBlacklistedInterface.cs (68%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs (72%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs (61%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs (80%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs (78%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/CustomGeneric.cs create mode 100644 src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/IFoo.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Entities/InterfaceWithBlacklistedBase.cs (68%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs (72%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/MyRecord.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Expected/class-with-blacklisted-base.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Expected/class-with-blacklisted-interface.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Expected/interface-with-blacklisted-base.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Blacklist/Expected/my-record.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CircularGenericConstraint/CircularGenericConstraintTest.cs (67%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CircularGenericConstraint/Entities/TestClasses.cs (94%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CircularGenericConstraint/Expected/ICicrularConstraintInterface.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CircularGenericConstraint/Expected/IMultipleConstraintInterface.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CircularGenericConstraint/Expected/IRecursiveConstraintInterface.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CircularGenericConstraint/Expected/IRecursiveConstraintInterfaceWithClassConstraint.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CircularGenericConstraint/Expected/IRecursiveConstraintInterfaceWithStructConstraint.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CircularGenericConstraint/Expected/RecursiveConstraintClass.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/CommentsTest.cs (63%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Entities/ITsInterface.cs (78%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Entities/TsClass.cs (93%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Entities/TsEnum.cs (87%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Entities/TsEnumUnion.cs (86%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Entities/TsGeneric.cs (81%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Expected/i-ts-interface-default-export.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Expected/i-ts-interface.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Expected/ts-class-default-export.ts (91%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Expected/ts-class.ts (91%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Expected/ts-enum-default-export.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Expected/ts-enum-union-default-export.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Expected/ts-enum-union.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Expected/ts-enum.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Expected/ts-generic-default-export.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Comments/Expected/ts-generic.ts (100%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/CommonCases/CommonCasesGenerationTest.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ArrayOfNullable.cs (69%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/BaseClass.cs (60%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/BaseClass2.cs (73%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/CircularRefClass1.cs (81%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/CircularRefClass2.cs (66%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Constants/FooConstants.cs (91%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Constants/Structs/FooConstants.cs (91%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/CustomBaseClass.cs (78%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/CustomBaseCustomImport.cs (77%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/CustomEmptyBaseClass.cs (78%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/CustomMappingsClassGenerationIssue/ClassWithUri.cs (71%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/DefaultMemberComplexValues.cs (83%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/DefaultMemberValues.cs (92%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/DictionaryStringObjectErrorCase.cs (77%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/DictionaryWithEnumKey.cs (78%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/EnumAsUnionType.cs (76%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/EnumShortValues.cs (71%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/EnumWithCustomHeadAndBody.cs (68%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ErrorCase/Bar.cs (86%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ErrorCase/C.cs (87%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ErrorCase/D.cs (96%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ErrorCase/EClass.cs (93%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ErrorCase/FClass.cs (88%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ErrorCase/Foo.cs (84%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ErrorCase/FooType.cs (66%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ExtendedPrimitivesClass.cs (93%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ExternalDepsClass.cs (79%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/GenericBaseClass.cs (67%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/GenericClass.cs (83%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/GenericWithRestrictions.cs (72%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ITestInterface.cs (81%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/JsonProperty/JsonPropertyTest.cs (79%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/LiteDbEntity.cs (81%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/NestedEntity.cs (84%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/NoSlashOutputDir.cs (78%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/NotGeneratedBaseClass.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/ReadonlyInterface.cs (73%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/StandaloneEnum.cs (72%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/StaticReadonly.cs (88%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/StrictNullsClass.cs (93%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/BaseClass.cs (59%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/CustomBaseClass.cs (76%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/CustomBaseCustomImport.cs (70%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/CustomEmptyBaseClass.cs (74%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/DefaultMemberComplexValues.cs (86%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/DefaultMemberValues.cs (93%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/ExtendedPrimitivesClass.cs (94%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/ExternalDepsClass.cs (77%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/GenericBaseClass.cs (58%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/GenericWithRestrictions.cs (71%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/IBar.cs create mode 100644 src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/IFoo.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/ITestInterface.cs (80%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/LiteDbEntity.cs (79%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/NoSlashOutputDir.cs (76%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/ReadonlyInterface.cs (71%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/StaticReadonly.cs (87%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/StrictNullsClass.cs (92%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/TestInterface.cs (74%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/Structs/TypeUnions.cs (87%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/TestClass.cs (96%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/TestEnum.cs (73%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/TestInterface.cs (77%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/TypeUnions.cs (88%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/WithGenericBaseClassCustomType.cs (76%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/WithIgnoredBase.cs (78%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Entities/WithIgnoredBaseAndCustomBase.cs (78%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/array-of-nullable.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/bar.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/base-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/base-class2.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/c.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/custom-base-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/custom-base-custom-import.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/custom-empty-base-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/d.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/default-member-values.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/default-member-values_struct.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/dictionary-string-object-error-case.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/dictionary-with-enum-key.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/e-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/enum-as-union-type.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/enum-short-values.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/extended-primitives-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/external-deps-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/f-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/foo-constants.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/foo-type.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/foo.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/generic-base-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/generic-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/generic-with-restrictions.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/i-test-interface.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/index.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/lite-db-entity.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/no/slash/output/dir/no-slash-output-dir.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/readonly-interface.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/standalone-enum.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/static-readonly.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/strict-nulls-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/test-classes/base-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/test-classes/base-class2.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/test-classes/circular-ref-class1.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/test-classes/circular-ref-class2.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/test-classes/test-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/test-enums/test-enum.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/test-interfaces/test-interface.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/type-unions.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/very/nested/directory/nested-entity.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/with-generic-base-class-custom-type.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/with-ignored-base-and-custom-base.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CommonCases/Expected/with-ignored-base.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ConstantsOnly/ConstantsOnlyTest.cs (77%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ConstantsOnly/Entities/ConstantsOnly.cs (91%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ConstantsOnly/Expected/constants-only.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Converters/JsonMemberNameConverter.cs (89%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Converters/PascalCaseToCamelCaseJsonConverter.cs (91%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CustomBaseInterfaces/CustomBaseInterfacesTest.cs (81%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CustomBaseInterfaces/Entities/Foo.cs (78%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/Entities/ITest.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CustomBaseInterfaces/Expected/foo.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CustomMappingsClassGeneration/CustomMappingsClassGeneration.cs (86%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/CustomMappingsClassGeneration/Expected/class-with-uri.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/DefaultExportTest.cs (58%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Entities/ClassWithDefaultExport.cs (75%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Entities/ClassWithImports.cs (92%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Entities/ClassWithoutDefaultExport.cs (73%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Entities/GenericClassWithDefaultExport.cs (76%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Entities/InterfaceWithDefaultExport.cs (76%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Entities/Structs/ClassWithDefaultExport.cs (73%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Entities/Structs/ClassWithImports.cs (91%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Entities/Structs/ClassWithoutDefaultExport.cs (71%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Entities/Structs/GenericClassWithDefaultExport.cs (74%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Entities/Structs/InterfaceWithDefaultExport.cs (74%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Expected/class-with-default-export.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Expected/class-with-imports.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Expected/class-without-default-export.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Expected/generic-class-with-default-export.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/DefaultExport/Expected/interface-with-default-export.ts (100%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Entities/Child.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ExportTypesAsInterfacesByDefault/Entities/Parent.cs (52%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ExportTypesAsInterfacesByDefault/Expected/child-as-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ExportTypesAsInterfacesByDefault/Expected/child-as-interface.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ExportTypesAsInterfacesByDefault/ExportTypesAsInterfacesByDefaultTest.cs (81%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/Extensions/StringExtensions.cs (85%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/GenerationSpecForStructs/GenerationSpecsForStructsTest.cs (68%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/Entities/ITest.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/IgnoreBaseInterfaces/Entities/Test.cs (68%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/IgnoreBaseInterfaces/Expected/test.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/IgnoreBaseInterfaces/IgnoreBaseInterfacesTest.cs (58%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/ImportType/Entities/DepClass.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ImportType/Entities/TsClass.cs (53%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ImportType/Expected/ts-class-default-export.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ImportType/Expected/ts-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/ImportType/ImportTypeTest.cs (71%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/NullableTranslation/Entities/NullableClass.cs (92%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/NullableTranslation/Expected/nullable-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/NullableTranslation/NullableTranslationTest.cs (79%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/StructImplementsInterfaces/Entities/ImplementsInterfaces.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/StructImplementsInterfaces/Expected/implements-interfaces.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/StructImplementsInterfaces/StructImplementsInterfacesTest.cs (61%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/TestingUtils/EmbededResourceReader.cs (89%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/TestingUtils/GeneratedOutput.cs (95%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/TestingUtils/GenerationTestBase.cs (93%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/TestingUtils/GeneratorOutputInterceptor.cs (97%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/Entities/TsClass.cs create mode 100644 src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/Entities/TsInterface.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/TsClassExtendsTsInterface/Expected/ts-class.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs (77%) create mode 100644 src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/Entities/Base.cs create mode 100644 src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/Entities/Sub.cs rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/TsInterfaceInheritance/Expected/sub.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs (78%) rename src/TypeGen/{TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj => TypeGen.FileContentTest/TypeGen.FileContentTest.csproj} (98%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/UseDefaultExportBreaksInterfaceInheritance/Entities/IId.cs (53%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/UseDefaultExportBreaksInterfaceInheritance/Entities/IIdentifier.cs (58%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/UseDefaultExportBreaksInterfaceInheritance/Entities/ProductDto.cs (69%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/UseDefaultExportBreaksInterfaceInheritance/Expected/product-dto.ts (100%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/UseDefaultExportBreaksInterfaceInheritance/UseDefaultExportBreaksInterfaceInheritanceTest.cs (81%) rename src/TypeGen/{TypeGen.IntegrationTest => TypeGen.FileContentTest}/tgconfig.json (100%) delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Bar.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Baz.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/CustomGeneric.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/IFoo.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/MyRecord.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/CommonCases/CommonCasesGenerationTest.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/NotGeneratedBaseClass.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/IBar.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/IFoo.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/Entities/ITest.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Entities/Child.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/Entities/ITest.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/ImportType/Entities/DepClass.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/StructImplementsInterfaces/Entities/ImplementsInterfaces.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsClass.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsInterface.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Base.cs delete mode 100644 src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Sub.cs diff --git a/.gitignore b/.gitignore index e641539a..63d89bf5 100644 --- a/.gitignore +++ b/.gitignore @@ -262,3 +262,5 @@ paket-files/ /src/TypeGen/TypeGen.Cli/NuGet.config /src/TypeGen/TypeGen.Core/TypeGen.Core.xml generated-typescript +/src/TypeGen/TypeGen.Core.Test/foo.ts +/src/TypeGen/TypeGen.Core.Test/tgconfig.json diff --git a/appveyor.yml b/appveyor.yml index cf112260..b4ecbaac 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,7 @@ before_build: - dotnet restore src/TypeGen/TypeGen.Core - dotnet restore src/TypeGen/TypeGen.Cli.Test - dotnet restore src/TypeGen/TypeGen.Core.Test - - dotnet restore src/TypeGen/TypeGen.IntegrationTest + - dotnet restore src/TypeGen/TypeGen.FileContentTest build: project: src/TypeGen/TypeGen.sln diff --git a/src/TypeGen/TypeGen.IntegrationTest/CliSmokeTest.cs b/src/TypeGen/TypeGen.Cli.Test/CliSmokeTest.cs similarity index 97% rename from src/TypeGen/TypeGen.IntegrationTest/CliSmokeTest.cs rename to src/TypeGen/TypeGen.Cli.Test/CliSmokeTest.cs index 25f03f73..27fb6268 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CliSmokeTest.cs +++ b/src/TypeGen/TypeGen.Cli.Test/CliSmokeTest.cs @@ -7,7 +7,7 @@ using FluentAssertions; using Xunit; -namespace TypeGen.IntegrationTest +namespace TypeGen.Cli.Test { public class CliSmokeTest { @@ -16,7 +16,7 @@ public void Cli_should_finish_with_success() { // arrange - const string projectToGeneratePath = "../../../../TypeGen.IntegrationTest"; + const string projectToGeneratePath = "../../../../TypeGen.FileContentTest"; const string cliFileName = "TypeGen.Cli.exe"; string[] cliPossibleDirectories = { "../../../../TypeGen.Cli/bin/Debug/net7.0", diff --git a/src/TypeGen/TypeGen.Cli/AssemblyInfo.cs b/src/TypeGen/TypeGen.Cli/AssemblyInfo.cs index 1c6e4a4b..1a7778c9 100644 --- a/src/TypeGen/TypeGen.Cli/AssemblyInfo.cs +++ b/src/TypeGen/TypeGen.Cli/AssemblyInfo.cs @@ -1,7 +1,7 @@ using System.Reflection; using System.Runtime.CompilerServices; -[assembly: InternalsVisibleTo("TypeGen.IntegrationTest")] +[assembly: InternalsVisibleTo("TypeGen.FileContentTest")] [assembly: InternalsVisibleTo("TypeGen.Cli.Test")] [assembly: InternalsVisibleTo("TypeGen.Core.Test")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/ExceptionShouldContainInitialType.cs b/src/TypeGen/TypeGen.Core.Test/Generator/ExceptionShouldContainInitialType.cs similarity index 85% rename from src/TypeGen/TypeGen.IntegrationTest/ExceptionShouldContainInitialType.cs rename to src/TypeGen/TypeGen.Core.Test/Generator/ExceptionShouldContainInitialType.cs index da7269d7..b014e8b1 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/ExceptionShouldContainInitialType.cs +++ b/src/TypeGen/TypeGen.Core.Test/Generator/ExceptionShouldContainInitialType.cs @@ -1,12 +1,10 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using TypeGen.Core; -using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; using Xunit; -namespace TypeGen.IntegrationTest; +namespace TypeGen.Core.Test.Generator; public class ExceptionShouldContainInitialType { @@ -18,10 +16,10 @@ public async Task ShouldThrowExceptionWithInitialTypeNameWhenDependencyTypeFails { var type = typeof(TestExceptions); var spec = new ExceptionsGenerationSpec(); - var generator = new Generator(); + var generator = new Core.Generator.Generator(); try { - await generator.GenerateAsync(new[] { spec }); + await generator.GenerateAsync(spec); Assert.True(true, "Exception not thrown"); } catch (CoreException ex) diff --git a/src/TypeGen/TypeGen.Core.Test/Generator/GeneratorTest.cs b/src/TypeGen/TypeGen.Core.Test/Generator/GeneratorTest.cs new file mode 100644 index 00000000..5f90aa58 --- /dev/null +++ b/src/TypeGen/TypeGen.Core.Test/Generator/GeneratorTest.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using FluentAssertions; +using NSubstitute; +using TypeGen.Core.Generator; +using TypeGen.Core.SpecGeneration; +using TypeGen.Core.Storage; +using Xunit; + +namespace TypeGen.Core.Test.Generator; + +public class GeneratorTest +{ + [Fact] + public async Task generation_callbacks_should_be_invoked_in_correct_order() + { + // arrange + var options = new GeneratorOptions(); + var fileSystemMock = Substitute.For(); + var generator = new Core.Generator.Generator(options, fileSystemMock); + var generationSpec = new GenerationCallbackOrderSpec(); + + // act + await generator.GenerateAsync(generationSpec); + + // assert + generationSpec.CallbackOrder.Should().BeEquivalentTo(new[] + { + nameof(GenerationSpec.OnBeforeGeneration), + nameof(GenerationSpec.OnBeforeBarrelGeneration), + nameof(GenerationSpec.OnAfterGeneration), + }); + } + + private class GenerationCallbackOrderSpec : GenerationSpec + { + public List CallbackOrder { get; } = new(); + + public GenerationCallbackOrderSpec() + { + AddClass(); + } + + public override void OnBeforeGeneration(OnBeforeGenerationArgs args) + { + base.OnBeforeGeneration(args); + CallbackOrder.Add(nameof(OnBeforeGeneration)); + Console.WriteLine(nameof(OnBeforeGeneration)); + } + + public override void OnBeforeBarrelGeneration(OnBeforeBarrelGenerationArgs args) + { + base.OnBeforeBarrelGeneration(args); + CallbackOrder.Add(nameof(OnBeforeBarrelGeneration)); + Console.WriteLine(nameof(OnBeforeBarrelGeneration)); + } + + public override void OnAfterGeneration(OnAfterGenerationArgs args) + { + base.OnAfterGeneration(args); + CallbackOrder.Add(nameof(OnAfterGeneration)); + Console.WriteLine(nameof(OnAfterGeneration)); + } + + private class Foo + { + public string HelloWorld { get; set; } + } + } +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/AssemblyInfo.cs b/src/TypeGen/TypeGen.Core/AssemblyInfo.cs index 4c9e01aa..ace9df75 100644 --- a/src/TypeGen/TypeGen.Core/AssemblyInfo.cs +++ b/src/TypeGen/TypeGen.Core/AssemblyInfo.cs @@ -2,7 +2,7 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("TypeGen.Cli")] -[assembly: InternalsVisibleTo("TypeGen.IntegrationTest")] +[assembly: InternalsVisibleTo("TypeGen.FileContentTest")] [assembly: InternalsVisibleTo("TypeGen.Cli.Test")] [assembly: InternalsVisibleTo("TypeGen.Core.Test")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] \ No newline at end of file diff --git a/src/TypeGen/TypeGen.Core/Generator/Generator.cs b/src/TypeGen/TypeGen.Core/Generator/Generator.cs index b43633d7..f8636184 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Generator.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Generator.cs @@ -109,6 +109,26 @@ public Task> GenerateAsync(IEnumerable gener { return Task.Run(() => Generate(generationSpecs)); } + + /// + /// Generates TypeScript files from a GenerationSpec + /// + /// + /// Generated TypeScript file paths (relative to the Options.BaseOutputDirectory) + public Task> GenerateAsync(params GenerationSpec[] generationSpecs) + { + return GenerateAsync((IEnumerable)generationSpecs); + } + + /// + /// Generates TypeScript sources from GenerationSpecs. + /// + /// + /// Generated TypeScript file paths (relative to the Options.BaseOutputDirectory) + public IEnumerable Generate(params GenerationSpec[] generationSpecs) + { + return Generate((IEnumerable)generationSpecs); + } /// /// Generates TypeScript sources from GenerationSpecs. diff --git a/src/TypeGen/TypeGen.Core/SpecGeneration/GenerationSpec.cs b/src/TypeGen/TypeGen.Core/SpecGeneration/GenerationSpec.cs index f21cec13..bf9b75d2 100644 --- a/src/TypeGen/TypeGen.Core/SpecGeneration/GenerationSpec.cs +++ b/src/TypeGen/TypeGen.Core/SpecGeneration/GenerationSpec.cs @@ -24,14 +24,27 @@ protected GenerationSpec() BarrelSpecs = new List(); } + /// + /// The callback invoked before any files from the current generation spec are generated. + /// + /// The callback arguments. public virtual void OnBeforeGeneration(OnBeforeGenerationArgs args) { } + /// + /// The callback invoked after the translated TypeScript files are generated from the current generation spec, + /// but before any barrel files are generated for the current generation spec. + /// + /// The callback arguments. public virtual void OnBeforeBarrelGeneration(OnBeforeBarrelGenerationArgs args) { } + /// + /// The callback invoked after all files from the current generation spec are generated. + /// + /// The callback arguments. public virtual void OnAfterGeneration(OnAfterGenerationArgs args) { } diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/BlacklistTest.cs similarity index 94% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/BlacklistTest.cs index f06c99bb..ad24dec8 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/BlacklistTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/BlacklistTest.cs @@ -5,11 +5,11 @@ using TypeGen.Core; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.Blacklist.Entities; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.Blacklist.Entities; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.Blacklist +namespace TypeGen.FileContentTest.Blacklist { public class BlacklistTest : GenerationTestBase { @@ -17,7 +17,7 @@ public class BlacklistTest : GenerationTestBase public async Task ClassWithBlacklistedBase_Test() { var type = typeof(ClassWithBlacklistedBase); - const string expectedLocation = "TypeGen.IntegrationTest.Blacklist.Expected.class-with-blacklisted-base.ts"; + const string expectedLocation = "TypeGen.FileContentTest.Blacklist.Expected.class-with-blacklisted-base.ts"; var blacklist = new HashSet { typeof(Bar).FullName }; var generationSpec = new ClassWithBlacklistedBaseGenerationSpec(); var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; @@ -29,7 +29,7 @@ public async Task ClassWithBlacklistedBase_Test() public async Task ClassWithBlacklistedInterface_Test() { var type = typeof(ClassWithBlacklistedInterface); - const string expectedLocation = "TypeGen.IntegrationTest.Blacklist.Expected.class-with-blacklisted-interface.ts"; + const string expectedLocation = "TypeGen.FileContentTest.Blacklist.Expected.class-with-blacklisted-interface.ts"; var blacklist = new HashSet { typeof(IFoo).FullName }; var generationSpec = new ClassWithBlacklistedInterfaceGenerationSpec(); var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; @@ -41,7 +41,7 @@ public async Task ClassWithBlacklistedInterface_Test() public async Task InterfaceWithBlacklistedBase_Test() { var type = typeof(InterfaceWithBlacklistedBase); - const string expectedLocation = "TypeGen.IntegrationTest.Blacklist.Expected.interface-with-blacklisted-base.ts"; + const string expectedLocation = "TypeGen.FileContentTest.Blacklist.Expected.interface-with-blacklisted-base.ts"; var blacklist = new HashSet { typeof(IFoo).FullName }; var generationSpec = new InterfaceWithBlacklistedBaseGenerationSpec(); var generatorOptions = new GeneratorOptions { TypeBlacklist = blacklist }; @@ -108,7 +108,7 @@ public void InterfaceWithBlacklistedPropertyType_Test() public async Task Record_Test() { var type = typeof(MyRecord); - const string expectedLocation = "TypeGen.IntegrationTest.Blacklist.Expected.my-record.ts"; + const string expectedLocation = "TypeGen.FileContentTest.Blacklist.Expected.my-record.ts"; var generationSpec = new RecordGenerationSpec(); var generatorOptions = new GeneratorOptions(); diff --git a/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/Bar.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/Bar.cs new file mode 100644 index 00000000..a0dd8bb5 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/Bar.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.Blacklist.Entities; + +public class Bar +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/Baz.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/Baz.cs new file mode 100644 index 00000000..79283f49 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/Baz.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.Blacklist.Entities; + +public class Baz +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedBase.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedBase.cs similarity index 67% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedBase.cs rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedBase.cs index 044ed8c7..3562e07a 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedBase.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedBase.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.Blacklist.Entities; +namespace TypeGen.FileContentTest.Blacklist.Entities; [ExportTsClass] public class ClassWithBlacklistedBase : Bar, IFoo diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedInterface.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedInterface.cs similarity index 68% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedInterface.cs rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedInterface.cs index 1adadef2..bccb8c5e 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedInterface.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedInterface.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.Blacklist.Entities; +namespace TypeGen.FileContentTest.Blacklist.Entities; [ExportTsClass] public class ClassWithBlacklistedInterface : Bar, IFoo diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs similarity index 72% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs index 0b5521ff..3c6728b6 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedPropertyType.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.Blacklist.Entities; +namespace TypeGen.FileContentTest.Blacklist.Entities; [ExportTsClass] public class ClassWithBlacklistedPropertyType diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs similarity index 61% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs index fdc8735d..55300af2 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedTypeInArray.cs @@ -1,7 +1,6 @@ -using System.Collections.Generic; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.Blacklist.Entities; +namespace TypeGen.FileContentTest.Blacklist.Entities; [ExportTsClass] public class ClassWithBlacklistedTypeInArray diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs similarity index 80% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs index e8180ec7..be65421a 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedTypeInCustomGeneric.cs @@ -1,7 +1,7 @@ using System; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.Blacklist.Entities; +namespace TypeGen.FileContentTest.Blacklist.Entities; [ExportTsClass] public class ClassWithBlacklistedTypeInCustomGeneric diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs similarity index 78% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs index c3348331..b34b9688 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/ClassWithBlacklistedTypeInDictionary.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.Blacklist.Entities; +namespace TypeGen.FileContentTest.Blacklist.Entities; [ExportTsClass] public class ClassWithBlacklistedTypeInDictionary diff --git a/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/CustomGeneric.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/CustomGeneric.cs new file mode 100644 index 00000000..1d0c2f80 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/CustomGeneric.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.Blacklist.Entities; + +public class CustomGeneric +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/IFoo.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/IFoo.cs new file mode 100644 index 00000000..84c22422 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/IFoo.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.Blacklist.Entities; + +public interface IFoo +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedBase.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/InterfaceWithBlacklistedBase.cs similarity index 68% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedBase.cs rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/InterfaceWithBlacklistedBase.cs index 39012a5a..2a85f21c 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedBase.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/InterfaceWithBlacklistedBase.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.Blacklist.Entities; +namespace TypeGen.FileContentTest.Blacklist.Entities; [ExportTsInterface] public interface InterfaceWithBlacklistedBase : IFoo diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs similarity index 72% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs index fedb95a1..790dc521 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/InterfaceWithBlacklistedPropertyType.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.Blacklist.Entities; +namespace TypeGen.FileContentTest.Blacklist.Entities; [ExportTsInterface] public interface InterfaceWithBlacklistedPropertyType diff --git a/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/MyRecord.cs b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/MyRecord.cs new file mode 100644 index 00000000..55f69345 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Entities/MyRecord.cs @@ -0,0 +1,3 @@ +namespace TypeGen.FileContentTest.Blacklist.Entities; + +public record MyRecord(); \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-base.ts b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Expected/class-with-blacklisted-base.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-base.ts rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Expected/class-with-blacklisted-base.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-interface.ts b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Expected/class-with-blacklisted-interface.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/class-with-blacklisted-interface.ts rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Expected/class-with-blacklisted-interface.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/interface-with-blacklisted-base.ts b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Expected/interface-with-blacklisted-base.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/interface-with-blacklisted-base.ts rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Expected/interface-with-blacklisted-base.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/my-record.ts b/src/TypeGen/TypeGen.FileContentTest/Blacklist/Expected/my-record.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Blacklist/Expected/my-record.ts rename to src/TypeGen/TypeGen.FileContentTest/Blacklist/Expected/my-record.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/CircularGenericConstraintTest.cs b/src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/CircularGenericConstraintTest.cs similarity index 67% rename from src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/CircularGenericConstraintTest.cs rename to src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/CircularGenericConstraintTest.cs index b2c6f119..637fa74e 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/CircularGenericConstraintTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/CircularGenericConstraintTest.cs @@ -1,11 +1,10 @@ using System; using System.Threading.Tasks; -using TypeGen.IntegrationTest.CircularGenericConstraint.Entities; -using TypeGen.IntegrationTest.CommonCases; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.CircularGenericConstraint.Entities; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.CircularGenericConstraint +namespace TypeGen.FileContentTest.CircularGenericConstraint { public class CircularGenericConstraintTest : GenerationTestBase { @@ -16,12 +15,12 @@ public class CircularGenericConstraintTest : GenerationTestBase /// /// [Theory] - [InlineData(typeof(RecursiveConstraintClass<>), @"TypeGen.IntegrationTest.CircularGenericConstraint.Expected.RecursiveConstraintClass.ts")] - [InlineData(typeof(IRecursiveConstraintInterface<>), @"TypeGen.IntegrationTest.CircularGenericConstraint.Expected.IRecursiveConstraintInterface.ts")] - [InlineData(typeof(IRecursiveConstraintInterfaceWithClassConstraint<>), @"TypeGen.IntegrationTest.CircularGenericConstraint.Expected.IRecursiveConstraintInterfaceWithClassConstraint.ts")] - [InlineData(typeof(IRecursiveConstraintInterfaceWithStructConstraint<>), @"TypeGen.IntegrationTest.CircularGenericConstraint.Expected.IRecursiveConstraintInterfaceWithStructConstraint.ts")] - [InlineData(typeof(IMultipleConstraintInterface<>), @"TypeGen.IntegrationTest.CircularGenericConstraint.Expected.IMultipleConstraintInterface.ts")] - [InlineData(typeof(ICicrularConstraintInterface<,>), @"TypeGen.IntegrationTest.CircularGenericConstraint.Expected.ICicrularConstraintInterface.ts")] + [InlineData(typeof(RecursiveConstraintClass<>), @"TypeGen.FileContentTest.CircularGenericConstraint.Expected.RecursiveConstraintClass.ts")] + [InlineData(typeof(IRecursiveConstraintInterface<>), @"TypeGen.FileContentTest.CircularGenericConstraint.Expected.IRecursiveConstraintInterface.ts")] + [InlineData(typeof(IRecursiveConstraintInterfaceWithClassConstraint<>), @"TypeGen.FileContentTest.CircularGenericConstraint.Expected.IRecursiveConstraintInterfaceWithClassConstraint.ts")] + [InlineData(typeof(IRecursiveConstraintInterfaceWithStructConstraint<>), @"TypeGen.FileContentTest.CircularGenericConstraint.Expected.IRecursiveConstraintInterfaceWithStructConstraint.ts")] + [InlineData(typeof(IMultipleConstraintInterface<>), @"TypeGen.FileContentTest.CircularGenericConstraint.Expected.IMultipleConstraintInterface.ts")] + [InlineData(typeof(ICicrularConstraintInterface<,>), @"TypeGen.FileContentTest.CircularGenericConstraint.Expected.ICicrularConstraintInterface.ts")] public async Task GeneratesCorrectly(Type type, string expectedLocation) { await TestFromAssembly(type, expectedLocation); diff --git a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Entities/TestClasses.cs b/src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Entities/TestClasses.cs similarity index 94% rename from src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Entities/TestClasses.cs rename to src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Entities/TestClasses.cs index d6469983..17e1ebd5 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Entities/TestClasses.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Entities/TestClasses.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CircularGenericConstraint.Entities +namespace TypeGen.FileContentTest.CircularGenericConstraint.Entities { [ExportTsClass] public class RecursiveConstraintClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/ICicrularConstraintInterface.ts b/src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/ICicrularConstraintInterface.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/ICicrularConstraintInterface.ts rename to src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/ICicrularConstraintInterface.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/IMultipleConstraintInterface.ts b/src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/IMultipleConstraintInterface.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/IMultipleConstraintInterface.ts rename to src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/IMultipleConstraintInterface.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterface.ts b/src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterface.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterface.ts rename to src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterface.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterfaceWithClassConstraint.ts b/src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterfaceWithClassConstraint.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterfaceWithClassConstraint.ts rename to src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterfaceWithClassConstraint.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterfaceWithStructConstraint.ts b/src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterfaceWithStructConstraint.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterfaceWithStructConstraint.ts rename to src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/IRecursiveConstraintInterfaceWithStructConstraint.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/RecursiveConstraintClass.ts b/src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/RecursiveConstraintClass.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CircularGenericConstraint/Expected/RecursiveConstraintClass.ts rename to src/TypeGen/TypeGen.FileContentTest/CircularGenericConstraint/Expected/RecursiveConstraintClass.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/CommentsTest.cs b/src/TypeGen/TypeGen.FileContentTest/Comments/CommentsTest.cs similarity index 63% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/CommentsTest.cs rename to src/TypeGen/TypeGen.FileContentTest/Comments/CommentsTest.cs index 921cf873..88374299 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Comments/CommentsTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Comments/CommentsTest.cs @@ -2,25 +2,25 @@ using System.Threading.Tasks; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.Comments.Entities; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.Comments.Entities; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.Comments; +namespace TypeGen.FileContentTest.Comments; public class CommentsTest : GenerationTestBase { [Theory] - [InlineData(typeof(TsClass), "TypeGen.IntegrationTest.Comments.Expected.ts-class.ts", false)] - [InlineData(typeof(TsClass), "TypeGen.IntegrationTest.Comments.Expected.ts-class-default-export.ts", true)] - [InlineData(typeof(TsGeneric<,>), "TypeGen.IntegrationTest.Comments.Expected.ts-generic.ts", false)] - [InlineData(typeof(TsGeneric<,>), "TypeGen.IntegrationTest.Comments.Expected.ts-generic-default-export.ts", true)] - [InlineData(typeof(ITsInterface), "TypeGen.IntegrationTest.Comments.Expected.i-ts-interface.ts", false)] - [InlineData(typeof(ITsInterface), "TypeGen.IntegrationTest.Comments.Expected.i-ts-interface-default-export.ts", true)] - [InlineData(typeof(TsEnum), "TypeGen.IntegrationTest.Comments.Expected.ts-enum.ts", false)] - [InlineData(typeof(TsEnum), "TypeGen.IntegrationTest.Comments.Expected.ts-enum-default-export.ts", true)] - [InlineData(typeof(TsEnumUnion), "TypeGen.IntegrationTest.Comments.Expected.ts-enum-union.ts", false)] - [InlineData(typeof(TsEnumUnion), "TypeGen.IntegrationTest.Comments.Expected.ts-enum-union-default-export.ts", true)] + [InlineData(typeof(TsClass), "TypeGen.FileContentTest.Comments.Expected.ts-class.ts", false)] + [InlineData(typeof(TsClass), "TypeGen.FileContentTest.Comments.Expected.ts-class-default-export.ts", true)] + [InlineData(typeof(TsGeneric<,>), "TypeGen.FileContentTest.Comments.Expected.ts-generic.ts", false)] + [InlineData(typeof(TsGeneric<,>), "TypeGen.FileContentTest.Comments.Expected.ts-generic-default-export.ts", true)] + [InlineData(typeof(ITsInterface), "TypeGen.FileContentTest.Comments.Expected.i-ts-interface.ts", false)] + [InlineData(typeof(ITsInterface), "TypeGen.FileContentTest.Comments.Expected.i-ts-interface-default-export.ts", true)] + [InlineData(typeof(TsEnum), "TypeGen.FileContentTest.Comments.Expected.ts-enum.ts", false)] + [InlineData(typeof(TsEnum), "TypeGen.FileContentTest.Comments.Expected.ts-enum-default-export.ts", true)] + [InlineData(typeof(TsEnumUnion), "TypeGen.FileContentTest.Comments.Expected.ts-enum-union.ts", false)] + [InlineData(typeof(TsEnumUnion), "TypeGen.FileContentTest.Comments.Expected.ts-enum-union-default-export.ts", true)] public async Task TestCommentsGenerationSpec(Type type, string expectedLocation, bool useDefaultExport) { var generationSpec = new CommentsGenerationSpec(); diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/ITsInterface.cs b/src/TypeGen/TypeGen.FileContentTest/Comments/Entities/ITsInterface.cs similarity index 78% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/ITsInterface.cs rename to src/TypeGen/TypeGen.FileContentTest/Comments/Entities/ITsInterface.cs index cf74f91f..648075c5 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/ITsInterface.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Comments/Entities/ITsInterface.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.Comments.Entities; +namespace TypeGen.FileContentTest.Comments.Entities; /// /// This is an interface. diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsClass.cs b/src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsClass.cs similarity index 93% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsClass.cs rename to src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsClass.cs index 7138a2a6..1052108d 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsClass.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.Comments.Entities; +namespace TypeGen.FileContentTest.Comments.Entities; /// /// This is the summary of TsClass. diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsEnum.cs b/src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsEnum.cs similarity index 87% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsEnum.cs rename to src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsEnum.cs index 23778979..04c63431 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsEnum.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsEnum.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.Comments.Entities; +namespace TypeGen.FileContentTest.Comments.Entities; /// /// I can't think of a good reason for this enum. diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsEnumUnion.cs b/src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsEnumUnion.cs similarity index 86% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsEnumUnion.cs rename to src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsEnumUnion.cs index 2d977956..3f2ced39 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsEnumUnion.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsEnumUnion.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.Comments.Entities; +namespace TypeGen.FileContentTest.Comments.Entities; /// /// This has union types. diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsGeneric.cs b/src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsGeneric.cs similarity index 81% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsGeneric.cs rename to src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsGeneric.cs index f14a3f70..9cfc3deb 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Comments/Entities/TsGeneric.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Comments/Entities/TsGeneric.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.Comments.Entities; +namespace TypeGen.FileContentTest.Comments.Entities; /// /// A very complicated generic type. diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/i-ts-interface-default-export.ts b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/i-ts-interface-default-export.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/i-ts-interface-default-export.ts rename to src/TypeGen/TypeGen.FileContentTest/Comments/Expected/i-ts-interface-default-export.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/i-ts-interface.ts b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/i-ts-interface.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/i-ts-interface.ts rename to src/TypeGen/TypeGen.FileContentTest/Comments/Expected/i-ts-interface.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-class-default-export.ts b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-class-default-export.ts similarity index 91% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-class-default-export.ts rename to src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-class-default-export.ts index 60ec6260..b4bad7c1 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-class-default-export.ts +++ b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-class-default-export.ts @@ -8,7 +8,7 @@ import TsEnum from "./ts-enum"; /** * This is the summary of TsClass. * It has many lines. - * This one is the last one. See @see {@link TypeGen.IntegrationTest.Comments.Entities.TsClass} for more details. + * This one is the last one. See @see {@link TypeGen.FileContentTest.Comments.Entities.TsClass} for more details. * * @example * This is how you can code: @see {@link http://example.com}. diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-class.ts b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-class.ts similarity index 91% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-class.ts rename to src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-class.ts index f0f47d16..8a664026 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-class.ts +++ b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-class.ts @@ -8,7 +8,7 @@ import { TsEnum } from "./ts-enum"; /** * This is the summary of TsClass. * It has many lines. - * This one is the last one. See @see {@link TypeGen.IntegrationTest.Comments.Entities.TsClass} for more details. + * This one is the last one. See @see {@link TypeGen.FileContentTest.Comments.Entities.TsClass} for more details. * * @example * This is how you can code: @see {@link http://example.com}. diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-enum-default-export.ts b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-enum-default-export.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-enum-default-export.ts rename to src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-enum-default-export.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-enum-union-default-export.ts b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-enum-union-default-export.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-enum-union-default-export.ts rename to src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-enum-union-default-export.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-enum-union.ts b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-enum-union.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-enum-union.ts rename to src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-enum-union.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-enum.ts b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-enum.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-enum.ts rename to src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-enum.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-generic-default-export.ts b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-generic-default-export.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-generic-default-export.ts rename to src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-generic-default-export.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-generic.ts b/src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-generic.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/Comments/Expected/ts-generic.ts rename to src/TypeGen/TypeGen.FileContentTest/Comments/Expected/ts-generic.ts diff --git a/src/TypeGen/TypeGen.FileContentTest/CommonCases/CommonCasesGenerationTest.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/CommonCasesGenerationTest.cs new file mode 100644 index 00000000..1e6daaff --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/CommonCasesGenerationTest.cs @@ -0,0 +1,103 @@ +using System; +using System.Threading.Tasks; +using TypeGen.FileContentTest.CommonCases.Entities; +using TypeGen.FileContentTest.CommonCases.Entities.Constants; +using TypeGen.FileContentTest.CommonCases.Entities.ErrorCase; +using TypeGen.FileContentTest.TestingUtils; +using Xunit; +using CustomBaseClass = TypeGen.FileContentTest.CommonCases.Entities.CustomBaseClass; +using CustomBaseCustomImport = TypeGen.FileContentTest.CommonCases.Entities.CustomBaseCustomImport; +using CustomEmptyBaseClass = TypeGen.FileContentTest.CommonCases.Entities.CustomEmptyBaseClass; +using DefaultMemberValues = TypeGen.FileContentTest.CommonCases.Entities.DefaultMemberValues; +using ExtendedPrimitivesClass = TypeGen.FileContentTest.CommonCases.Entities.ExtendedPrimitivesClass; +using ExternalDepsClass = TypeGen.FileContentTest.CommonCases.Entities.ExternalDepsClass; +using ITestInterface = TypeGen.FileContentTest.CommonCases.Entities.ITestInterface; +using LiteDbEntity = TypeGen.FileContentTest.CommonCases.Entities.LiteDbEntity; +using NoSlashOutputDir = TypeGen.FileContentTest.CommonCases.Entities.NoSlashOutputDir; +using ReadonlyInterface = TypeGen.FileContentTest.CommonCases.Entities.ReadonlyInterface; +using StaticReadonly = TypeGen.FileContentTest.CommonCases.Entities.StaticReadonly; +using StrictNullsClass = TypeGen.FileContentTest.CommonCases.Entities.StrictNullsClass; +using TestInterface = TypeGen.FileContentTest.CommonCases.Entities.TestInterface; +using TypeUnions = TypeGen.FileContentTest.CommonCases.Entities.TypeUnions; + +namespace TypeGen.FileContentTest.CommonCases +{ + public class CommonCasesGenerationTest : GenerationTestBase + { + /// + /// Tests if types are correctly translated to TypeScript. + /// The tested types contain all major use cases that should be supported. + /// + /// + /// + /// + [Theory] + [InlineData(typeof(FooConstants), "TypeGen.FileContentTest.CommonCases.Expected.foo-constants.ts")] + [InlineData(typeof(CustomBaseCustomImport), "TypeGen.FileContentTest.CommonCases.Expected.custom-base-custom-import.ts")] + [InlineData(typeof(Bar), "TypeGen.FileContentTest.CommonCases.Expected.bar.ts")] + [InlineData(typeof(Entities.BaseClass<>), "TypeGen.FileContentTest.CommonCases.Expected.base-class.ts")] + [InlineData(typeof(BaseClass2<>), "TypeGen.FileContentTest.CommonCases.Expected.base-class2.ts")] + [InlineData(typeof(C), "TypeGen.FileContentTest.CommonCases.Expected.c.ts")] + [InlineData(typeof(CustomBaseClass), "TypeGen.FileContentTest.CommonCases.Expected.custom-base-class.ts")] + [InlineData(typeof(CustomEmptyBaseClass), "TypeGen.FileContentTest.CommonCases.Expected.custom-empty-base-class.ts")] + [InlineData(typeof(D), "TypeGen.FileContentTest.CommonCases.Expected.d.ts")] + [InlineData(typeof(DefaultMemberValues), "TypeGen.FileContentTest.CommonCases.Expected.default-member-values.ts")] + [InlineData(typeof(EClass), "TypeGen.FileContentTest.CommonCases.Expected.e-class.ts")] + [InlineData(typeof(ExtendedPrimitivesClass), "TypeGen.FileContentTest.CommonCases.Expected.extended-primitives-class.ts")] + [InlineData(typeof(ExternalDepsClass), "TypeGen.FileContentTest.CommonCases.Expected.external-deps-class.ts")] + [InlineData(typeof(FClass), "TypeGen.FileContentTest.CommonCases.Expected.f-class.ts")] + [InlineData(typeof(FooType), "TypeGen.FileContentTest.CommonCases.Expected.foo-type.ts")] + [InlineData(typeof(Foo), "TypeGen.FileContentTest.CommonCases.Expected.foo.ts")] + [InlineData(typeof(Entities.GenericBaseClass<>), "TypeGen.FileContentTest.CommonCases.Expected.generic-base-class.ts")] + [InlineData(typeof(GenericClass<>), "TypeGen.FileContentTest.CommonCases.Expected.generic-class.ts")] + [InlineData(typeof(Entities.GenericWithRestrictions<>), "TypeGen.FileContentTest.CommonCases.Expected.generic-with-restrictions.ts")] + [InlineData(typeof(ITestInterface), "TypeGen.FileContentTest.CommonCases.Expected.i-test-interface.ts")] + [InlineData(typeof(LiteDbEntity), "TypeGen.FileContentTest.CommonCases.Expected.lite-db-entity.ts")] + [InlineData(typeof(ReadonlyInterface), "TypeGen.FileContentTest.CommonCases.Expected.readonly-interface.ts")] + [InlineData(typeof(StandaloneEnum), "TypeGen.FileContentTest.CommonCases.Expected.standalone-enum.ts")] + [InlineData(typeof(EnumShortValues), "TypeGen.FileContentTest.CommonCases.Expected.enum-short-values.ts")] + [InlineData(typeof(EnumAsUnionType), "TypeGen.FileContentTest.CommonCases.Expected.enum-as-union-type.ts")] + [InlineData(typeof(DictionaryWithEnumKey), "TypeGen.FileContentTest.CommonCases.Expected.dictionary-with-enum-key.ts")] + [InlineData(typeof(DictionaryStringObjectErrorCase), "TypeGen.FileContentTest.CommonCases.Expected.dictionary-string-object-error-case.ts")] + [InlineData(typeof(StaticReadonly), "TypeGen.FileContentTest.CommonCases.Expected.static-readonly.ts")] + [InlineData(typeof(StrictNullsClass), "TypeGen.FileContentTest.CommonCases.Expected.strict-nulls-class.ts")] + [InlineData(typeof(TypeUnions), "TypeGen.FileContentTest.CommonCases.Expected.type-unions.ts")] + [InlineData(typeof(WithGenericBaseClassCustomType), "TypeGen.FileContentTest.CommonCases.Expected.with-generic-base-class-custom-type.ts")] + [InlineData(typeof(WithIgnoredBaseAndCustomBase), "TypeGen.FileContentTest.CommonCases.Expected.with-ignored-base-and-custom-base.ts")] + [InlineData(typeof(WithIgnoredBase), "TypeGen.FileContentTest.CommonCases.Expected.with-ignored-base.ts")] + [InlineData(typeof(NoSlashOutputDir), "TypeGen.FileContentTest.CommonCases.Expected.no.slash.output.dir.no-slash-output-dir.ts")] + [InlineData(typeof(Entities.BaseClass<>), "TypeGen.FileContentTest.CommonCases.Expected.test_classes.base-class.ts")] + [InlineData(typeof(BaseClass2<>), "TypeGen.FileContentTest.CommonCases.Expected.test_classes.base-class2.ts")] + [InlineData(typeof(CircularRefClass1), "TypeGen.FileContentTest.CommonCases.Expected.test_classes.circular-ref-class1.ts")] + [InlineData(typeof(CircularRefClass2), "TypeGen.FileContentTest.CommonCases.Expected.test_classes.circular-ref-class2.ts")] + [InlineData(typeof(TestClass<,>), "TypeGen.FileContentTest.CommonCases.Expected.test_classes.test-class.ts")] + [InlineData(typeof(TestEnum), "TypeGen.FileContentTest.CommonCases.Expected.test_enums.test-enum.ts")] + [InlineData(typeof(TestInterface), "TypeGen.FileContentTest.CommonCases.Expected.test_interfaces.test-interface.ts")] + [InlineData(typeof(NestedEntity), "TypeGen.FileContentTest.CommonCases.Expected.very.nested.directory.nested-entity.ts")] + [InlineData(typeof(ArrayOfNullable), "TypeGen.FileContentTest.CommonCases.Expected.array-of-nullable.ts")] + + // now do the cases above for structs (when possible) + + [InlineData(typeof(Entities.Constants.Structs.FooConstants), "TypeGen.FileContentTest.CommonCases.Expected.foo-constants.ts")] + [InlineData(typeof(Entities.Structs.CustomBaseCustomImport), "TypeGen.FileContentTest.CommonCases.Expected.custom-base-custom-import.ts")] + [InlineData(typeof(Entities.Structs.CustomBaseClass), "TypeGen.FileContentTest.CommonCases.Expected.custom-base-class.ts")] + [InlineData(typeof(Entities.Structs.CustomEmptyBaseClass), "TypeGen.FileContentTest.CommonCases.Expected.custom-empty-base-class.ts")] + [InlineData(typeof(Entities.Structs.DefaultMemberValues), "TypeGen.FileContentTest.CommonCases.Expected.default-member-values_struct.ts")] + [InlineData(typeof(Entities.Structs.ExtendedPrimitivesClass), "TypeGen.FileContentTest.CommonCases.Expected.extended-primitives-class.ts")] + [InlineData(typeof(Entities.Structs.ExternalDepsClass), "TypeGen.FileContentTest.CommonCases.Expected.external-deps-class.ts")] + [InlineData(typeof(Entities.Structs.GenericBaseClass<>), "TypeGen.FileContentTest.CommonCases.Expected.generic-base-class.ts")] + [InlineData(typeof(Entities.Structs.GenericWithRestrictions<>), "TypeGen.FileContentTest.CommonCases.Expected.generic-with-restrictions.ts")] + [InlineData(typeof(Entities.Structs.ITestInterface), "TypeGen.FileContentTest.CommonCases.Expected.i-test-interface.ts")] + [InlineData(typeof(Entities.Structs.LiteDbEntity), "TypeGen.FileContentTest.CommonCases.Expected.lite-db-entity.ts")] + [InlineData(typeof(Entities.Structs.ReadonlyInterface), "TypeGen.FileContentTest.CommonCases.Expected.readonly-interface.ts")] + [InlineData(typeof(Entities.Structs.StaticReadonly), "TypeGen.FileContentTest.CommonCases.Expected.static-readonly.ts")] + [InlineData(typeof(Entities.Structs.StrictNullsClass), "TypeGen.FileContentTest.CommonCases.Expected.strict-nulls-class.ts")] + [InlineData(typeof(Entities.Structs.TypeUnions), "TypeGen.FileContentTest.CommonCases.Expected.type-unions.ts")] + [InlineData(typeof(Entities.Structs.NoSlashOutputDir), "TypeGen.FileContentTest.CommonCases.Expected.no.slash.output.dir.no-slash-output-dir.ts")] + [InlineData(typeof(Entities.Structs.TestInterface), "TypeGen.FileContentTest.CommonCases.Expected.test_interfaces.test-interface.ts")] + public async Task TestCommonCases(Type type, string expectedLocation) + { + await TestFromAssembly(type, expectedLocation); + } + } +} diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ArrayOfNullable.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ArrayOfNullable.cs similarity index 69% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ArrayOfNullable.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ArrayOfNullable.cs index 6b55eceb..1b894a9a 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ArrayOfNullable.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ArrayOfNullable.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities; +namespace TypeGen.FileContentTest.CommonCases.Entities; [ExportTsClass] public class ArrayOfNullable diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/BaseClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/BaseClass.cs similarity index 60% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/BaseClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/BaseClass.cs index 57de8a2b..72c07298 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/BaseClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/BaseClass.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { public class BaseClass { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/BaseClass2.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/BaseClass2.cs similarity index 73% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/BaseClass2.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/BaseClass2.cs index c1e87f1c..4561e58d 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/BaseClass2.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/BaseClass2.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { public abstract class BaseClass2 { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CircularRefClass1.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CircularRefClass1.cs similarity index 81% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CircularRefClass1.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CircularRefClass1.cs index f4efdd64..2d97018f 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CircularRefClass1.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CircularRefClass1.cs @@ -1,7 +1,7 @@ using System; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { public class CircularRefClass1 { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CircularRefClass2.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CircularRefClass2.cs similarity index 66% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CircularRefClass2.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CircularRefClass2.cs index 89dab4f5..555f68ed 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CircularRefClass2.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CircularRefClass2.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { public class CircularRefClass2 { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Constants/FooConstants.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Constants/FooConstants.cs similarity index 91% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Constants/FooConstants.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Constants/FooConstants.cs index eb4d7a23..55e2accc 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Constants/FooConstants.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Constants/FooConstants.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Constants +namespace TypeGen.FileContentTest.CommonCases.Entities.Constants { [ExportTsClass] public static class FooConstants diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Constants/Structs/FooConstants.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Constants/Structs/FooConstants.cs similarity index 91% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Constants/Structs/FooConstants.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Constants/Structs/FooConstants.cs index c610cdc7..38400ced 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Constants/Structs/FooConstants.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Constants/Structs/FooConstants.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Constants.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Constants.Structs { [ExportTsClass] public struct FooConstants diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomBaseClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomBaseClass.cs similarity index 78% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomBaseClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomBaseClass.cs index e93ae45c..c31edcf9 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomBaseClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomBaseClass.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] [TsCustomBase("AcmeCustomBase")] diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomBaseCustomImport.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomBaseCustomImport.cs similarity index 77% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomBaseCustomImport.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomBaseCustomImport.cs index 765b39ab..39558a3d 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomBaseCustomImport.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomBaseCustomImport.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsInterface] [TsCustomBase("MB", "./my/base/my-base", "MyBase")] diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomEmptyBaseClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomEmptyBaseClass.cs similarity index 78% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomEmptyBaseClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomEmptyBaseClass.cs index 21e27338..d64d1216 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomEmptyBaseClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomEmptyBaseClass.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsInterface] [TsCustomBase] diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomMappingsClassGenerationIssue/ClassWithUri.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomMappingsClassGenerationIssue/ClassWithUri.cs similarity index 71% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomMappingsClassGenerationIssue/ClassWithUri.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomMappingsClassGenerationIssue/ClassWithUri.cs index 22194965..93677fb0 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/CustomMappingsClassGenerationIssue/ClassWithUri.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/CustomMappingsClassGenerationIssue/ClassWithUri.cs @@ -1,7 +1,7 @@ using System; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.CustomMappingsClassGenerationIssue; +namespace TypeGen.FileContentTest.CommonCases.Entities.CustomMappingsClassGenerationIssue; [ExportTsClass] public class ClassWithUri diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DefaultMemberComplexValues.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DefaultMemberComplexValues.cs similarity index 83% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DefaultMemberComplexValues.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DefaultMemberComplexValues.cs index 20f33373..8d8bd86b 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DefaultMemberComplexValues.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DefaultMemberComplexValues.cs @@ -1,6 +1,6 @@ #nullable enable -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { public class DefaultMemberComplexValues { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DefaultMemberValues.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DefaultMemberValues.cs similarity index 92% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DefaultMemberValues.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DefaultMemberValues.cs index a8c3c1c6..8c0e84aa 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DefaultMemberValues.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DefaultMemberValues.cs @@ -1,7 +1,7 @@ using System; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class DefaultMemberValues diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DictionaryStringObjectErrorCase.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DictionaryStringObjectErrorCase.cs similarity index 77% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DictionaryStringObjectErrorCase.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DictionaryStringObjectErrorCase.cs index 139dfbe7..963af2a2 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DictionaryStringObjectErrorCase.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DictionaryStringObjectErrorCase.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities; +namespace TypeGen.FileContentTest.CommonCases.Entities; [ExportTsClass] public class DictionaryStringObjectErrorCase diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DictionaryWithEnumKey.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DictionaryWithEnumKey.cs similarity index 78% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DictionaryWithEnumKey.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DictionaryWithEnumKey.cs index 32782800..945c5405 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/DictionaryWithEnumKey.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/DictionaryWithEnumKey.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities; +namespace TypeGen.FileContentTest.CommonCases.Entities; [ExportTsClass] public class DictionaryWithEnumKey diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/EnumAsUnionType.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/EnumAsUnionType.cs similarity index 76% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/EnumAsUnionType.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/EnumAsUnionType.cs index 9a805dd3..6bcd91b9 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/EnumAsUnionType.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/EnumAsUnionType.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsEnum(AsUnionType = true)] public enum EnumAsUnionType diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/EnumShortValues.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/EnumShortValues.cs similarity index 71% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/EnumShortValues.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/EnumShortValues.cs index 12fa2805..521af860 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/EnumShortValues.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/EnumShortValues.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsEnum] public enum EnumShortValues : short diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/EnumWithCustomHeadAndBody.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/EnumWithCustomHeadAndBody.cs similarity index 68% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/EnumWithCustomHeadAndBody.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/EnumWithCustomHeadAndBody.cs index 9dbd2b7f..16a77e90 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/EnumWithCustomHeadAndBody.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/EnumWithCustomHeadAndBody.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities; +namespace TypeGen.FileContentTest.CommonCases.Entities; [ExportTsEnum] public enum EnumWithCustomHeadAndBody diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/Bar.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/Bar.cs similarity index 86% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/Bar.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/Bar.cs index 496eff44..1610ff52 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/Bar.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/Bar.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace TypeGen.IntegrationTest.CommonCases.Entities.ErrorCase +namespace TypeGen.FileContentTest.CommonCases.Entities.ErrorCase { public class Bar { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/C.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/C.cs similarity index 87% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/C.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/C.cs index 24263531..648e3af5 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/C.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/C.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace TypeGen.IntegrationTest.CommonCases.Entities.ErrorCase +namespace TypeGen.FileContentTest.CommonCases.Entities.ErrorCase { public class C { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/D.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/D.cs similarity index 96% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/D.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/D.cs index 29222c62..78257181 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/D.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/D.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.ErrorCase +namespace TypeGen.FileContentTest.CommonCases.Entities.ErrorCase { public class D : GenericClass { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/EClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/EClass.cs similarity index 93% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/EClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/EClass.cs index 75271d15..6676e634 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/EClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/EClass.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.ErrorCase +namespace TypeGen.FileContentTest.CommonCases.Entities.ErrorCase { public class EClass : GenericClass { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/FClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/FClass.cs similarity index 88% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/FClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/FClass.cs index c0880e0d..6ed0a407 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/FClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/FClass.cs @@ -1,6 +1,6 @@ using System.ComponentModel.DataAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.ErrorCase +namespace TypeGen.FileContentTest.CommonCases.Entities.ErrorCase { public class FClass : GenericClass { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/Foo.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/Foo.cs similarity index 84% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/Foo.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/Foo.cs index 9ce88aa1..fa242c59 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/Foo.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/Foo.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.ErrorCase +namespace TypeGen.FileContentTest.CommonCases.Entities.ErrorCase { [ExportTsClass] public class Foo diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/FooType.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/FooType.cs similarity index 66% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/FooType.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/FooType.cs index 3f740359..6d581cd4 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ErrorCase/FooType.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ErrorCase/FooType.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.CommonCases.Entities.ErrorCase +namespace TypeGen.FileContentTest.CommonCases.Entities.ErrorCase { public enum FooType { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ExtendedPrimitivesClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ExtendedPrimitivesClass.cs similarity index 93% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ExtendedPrimitivesClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ExtendedPrimitivesClass.cs index 4cc46ad1..3c34f845 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ExtendedPrimitivesClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ExtendedPrimitivesClass.cs @@ -1,7 +1,7 @@ using System; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class ExtendedPrimitivesClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ExternalDepsClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ExternalDepsClass.cs similarity index 79% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ExternalDepsClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ExternalDepsClass.cs index 39cb5bf6..a1872a75 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ExternalDepsClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ExternalDepsClass.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Identity; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class ExternalDepsClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/GenericBaseClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/GenericBaseClass.cs similarity index 67% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/GenericBaseClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/GenericBaseClass.cs index 38897f31..32dfd969 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/GenericBaseClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/GenericBaseClass.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class GenericBaseClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/GenericClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/GenericClass.cs similarity index 83% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/GenericClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/GenericClass.cs index 277c380d..5c34fae1 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/GenericClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/GenericClass.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class GenericClass : GenericBaseClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/GenericWithRestrictions.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/GenericWithRestrictions.cs similarity index 72% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/GenericWithRestrictions.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/GenericWithRestrictions.cs index 1194d009..777b1789 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/GenericWithRestrictions.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/GenericWithRestrictions.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class GenericWithRestrictions where T: TestInterface diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ITestInterface.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ITestInterface.cs similarity index 81% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ITestInterface.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ITestInterface.cs index a6a0d43e..e135005d 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ITestInterface.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ITestInterface.cs @@ -1,7 +1,7 @@ using System; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsInterface] public interface ITestInterface diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/JsonProperty/JsonPropertyTest.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/JsonProperty/JsonPropertyTest.cs similarity index 79% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/JsonProperty/JsonPropertyTest.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/JsonProperty/JsonPropertyTest.cs index 00561870..98b15c75 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/JsonProperty/JsonPropertyTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/JsonProperty/JsonPropertyTest.cs @@ -1,7 +1,7 @@ using Newtonsoft.Json; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.JsonProperty +namespace TypeGen.FileContentTest.CommonCases.Entities.JsonProperty { [ExportTsClass(OutputDir = "json-property-test")] public class JsonPropertyTest diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/LiteDbEntity.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/LiteDbEntity.cs similarity index 81% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/LiteDbEntity.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/LiteDbEntity.cs index 9a7cd432..91fd905b 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/LiteDbEntity.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/LiteDbEntity.cs @@ -1,7 +1,7 @@ using LiteDB; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class LiteDbEntity diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/NestedEntity.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/NestedEntity.cs similarity index 84% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/NestedEntity.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/NestedEntity.cs index 743cab14..0bfea944 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/NestedEntity.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/NestedEntity.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsInterface(OutputDir = "./very/nested/directory/")] public class NestedEntity diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/NoSlashOutputDir.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/NoSlashOutputDir.cs similarity index 78% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/NoSlashOutputDir.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/NoSlashOutputDir.cs index be92f91a..76888711 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/NoSlashOutputDir.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/NoSlashOutputDir.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass(OutputDir = "no/slash/output/dir")] public class NoSlashOutputDir diff --git a/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/NotGeneratedBaseClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/NotGeneratedBaseClass.cs new file mode 100644 index 00000000..1819e4f2 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/NotGeneratedBaseClass.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.CommonCases.Entities +{ + public class NotGeneratedBaseClass + { + } +} diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ReadonlyInterface.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ReadonlyInterface.cs similarity index 73% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ReadonlyInterface.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ReadonlyInterface.cs index bf172b44..6e367c8a 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/ReadonlyInterface.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/ReadonlyInterface.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsInterface] public class ReadonlyInterface diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/StandaloneEnum.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/StandaloneEnum.cs similarity index 72% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/StandaloneEnum.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/StandaloneEnum.cs index cb876aa6..98e85329 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/StandaloneEnum.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/StandaloneEnum.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsEnum] public enum StandaloneEnum diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/StaticReadonly.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/StaticReadonly.cs similarity index 88% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/StaticReadonly.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/StaticReadonly.cs index bf8cc3fa..f29d45b4 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/StaticReadonly.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/StaticReadonly.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class StaticReadonly diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/StrictNullsClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/StrictNullsClass.cs similarity index 93% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/StrictNullsClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/StrictNullsClass.cs index 1fc2d0ca..5f6b013e 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/StrictNullsClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/StrictNullsClass.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class StrictNullsClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/BaseClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/BaseClass.cs similarity index 59% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/BaseClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/BaseClass.cs index c7e3da82..46f546fe 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/BaseClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/BaseClass.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { public struct BaseClass { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/CustomBaseClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/CustomBaseClass.cs similarity index 76% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/CustomBaseClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/CustomBaseClass.cs index d15dc290..671175cf 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/CustomBaseClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/CustomBaseClass.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsClass] [TsCustomBase("AcmeCustomBase")] diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/CustomBaseCustomImport.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/CustomBaseCustomImport.cs similarity index 70% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/CustomBaseCustomImport.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/CustomBaseCustomImport.cs index ececf2eb..2ca02e70 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/CustomBaseCustomImport.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/CustomBaseCustomImport.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs; +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs; [ExportTsInterface] [TsCustomBase("MB", "./my/base/my-base", "MyBase")] diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/CustomEmptyBaseClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/CustomEmptyBaseClass.cs similarity index 74% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/CustomEmptyBaseClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/CustomEmptyBaseClass.cs index eab9811c..b569e0fe 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/CustomEmptyBaseClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/CustomEmptyBaseClass.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsInterface] [TsCustomBase] diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/DefaultMemberComplexValues.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/DefaultMemberComplexValues.cs similarity index 86% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/DefaultMemberComplexValues.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/DefaultMemberComplexValues.cs index d5f0bfb0..d455e309 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/DefaultMemberComplexValues.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/DefaultMemberComplexValues.cs @@ -1,6 +1,6 @@ #nullable enable -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { public struct DefaultMemberComplexValues { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/DefaultMemberValues.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/DefaultMemberValues.cs similarity index 93% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/DefaultMemberValues.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/DefaultMemberValues.cs index 5a88c29e..14692a34 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/DefaultMemberValues.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/DefaultMemberValues.cs @@ -1,7 +1,7 @@ using System; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsClass] public struct DefaultMemberValues diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ExtendedPrimitivesClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ExtendedPrimitivesClass.cs similarity index 94% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ExtendedPrimitivesClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ExtendedPrimitivesClass.cs index e57fe2e8..5aab5639 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ExtendedPrimitivesClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ExtendedPrimitivesClass.cs @@ -1,7 +1,7 @@ using System; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsClass] public struct ExtendedPrimitivesClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ExternalDepsClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ExternalDepsClass.cs similarity index 77% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ExternalDepsClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ExternalDepsClass.cs index d8d96921..65e3c306 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ExternalDepsClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ExternalDepsClass.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Identity; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsClass] public struct ExternalDepsClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/GenericBaseClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/GenericBaseClass.cs similarity index 58% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/GenericBaseClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/GenericBaseClass.cs index 5b05a8b9..e5a23fec 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/GenericBaseClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/GenericBaseClass.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs; +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs; [ExportTsClass] public struct GenericBaseClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/GenericWithRestrictions.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/GenericWithRestrictions.cs similarity index 71% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/GenericWithRestrictions.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/GenericWithRestrictions.cs index ee9372de..8c1516fc 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/GenericWithRestrictions.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/GenericWithRestrictions.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsClass] public struct GenericWithRestrictions where T: Entities.TestInterface diff --git a/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/IBar.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/IBar.cs new file mode 100644 index 00000000..a832d8ae --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/IBar.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs; + +public interface IBar +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/IFoo.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/IFoo.cs new file mode 100644 index 00000000..9cdebd35 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/IFoo.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs; + +public interface IFoo +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ITestInterface.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ITestInterface.cs similarity index 80% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ITestInterface.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ITestInterface.cs index 77bf281d..9c9102d1 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ITestInterface.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ITestInterface.cs @@ -1,7 +1,7 @@ using System; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsInterface] public struct ITestInterface diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/LiteDbEntity.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/LiteDbEntity.cs similarity index 79% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/LiteDbEntity.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/LiteDbEntity.cs index d230bc0e..982ff641 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/LiteDbEntity.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/LiteDbEntity.cs @@ -1,7 +1,7 @@ using LiteDB; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsClass] public struct LiteDbEntity diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/NoSlashOutputDir.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/NoSlashOutputDir.cs similarity index 76% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/NoSlashOutputDir.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/NoSlashOutputDir.cs index a0734de2..c01009b0 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/NoSlashOutputDir.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/NoSlashOutputDir.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsClass(OutputDir = "no/slash/output/dir")] public struct NoSlashOutputDir diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ReadonlyInterface.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ReadonlyInterface.cs similarity index 71% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ReadonlyInterface.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ReadonlyInterface.cs index 2460c444..e5f8d99b 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/ReadonlyInterface.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/ReadonlyInterface.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsInterface] public struct ReadonlyInterface diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/StaticReadonly.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/StaticReadonly.cs similarity index 87% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/StaticReadonly.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/StaticReadonly.cs index 9a48e570..df828a53 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/StaticReadonly.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/StaticReadonly.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsClass] public struct StaticReadonly diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/StrictNullsClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/StrictNullsClass.cs similarity index 92% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/StrictNullsClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/StrictNullsClass.cs index 529e9279..4e265e7a 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/StrictNullsClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/StrictNullsClass.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsClass] public struct StrictNullsClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/TestInterface.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/TestInterface.cs similarity index 74% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/TestInterface.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/TestInterface.cs index 27a1c9fa..e98f3691 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/TestInterface.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/TestInterface.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsInterface(OutputDir = "test-interfaces")] public struct TestInterface diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/TypeUnions.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/TypeUnions.cs similarity index 87% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/TypeUnions.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/TypeUnions.cs index 8683d1ca..3ea310a6 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/TypeUnions.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/Structs/TypeUnions.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs +namespace TypeGen.FileContentTest.CommonCases.Entities.Structs { [ExportTsClass] public struct TypeUnions diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TestClass.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TestClass.cs similarity index 96% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TestClass.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TestClass.cs index c0aa0774..338508a7 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TestClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TestClass.cs @@ -3,7 +3,7 @@ using System.Text.RegularExpressions; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass(OutputDir = "test-classes")] public class TestClass : BaseClass where U : BaseClass2 diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TestEnum.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TestEnum.cs similarity index 73% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TestEnum.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TestEnum.cs index 2dc9e277..bf9393a1 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TestEnum.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TestEnum.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsEnum(OutputDir = "test-enums", IsConst = true)] public enum TestEnum diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TestInterface.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TestInterface.cs similarity index 77% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TestInterface.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TestInterface.cs index b5809f30..c32dd90e 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TestInterface.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TestInterface.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsInterface(OutputDir = "test-interfaces")] public class TestInterface diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TypeUnions.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TypeUnions.cs similarity index 88% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TypeUnions.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TypeUnions.cs index 315020bf..df2b6ac8 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/TypeUnions.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/TypeUnions.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class TypeUnions diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/WithGenericBaseClassCustomType.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/WithGenericBaseClassCustomType.cs similarity index 76% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/WithGenericBaseClassCustomType.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/WithGenericBaseClassCustomType.cs index 7e742122..cf9ee46a 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/WithGenericBaseClassCustomType.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/WithGenericBaseClassCustomType.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] public class WithGenericBaseClassCustomType : BaseClass>> diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/WithIgnoredBase.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/WithIgnoredBase.cs similarity index 78% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/WithIgnoredBase.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/WithIgnoredBase.cs index c4536141..201065a0 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/WithIgnoredBase.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/WithIgnoredBase.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] [TsIgnoreBase] diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/WithIgnoredBaseAndCustomBase.cs b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/WithIgnoredBaseAndCustomBase.cs similarity index 78% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/WithIgnoredBaseAndCustomBase.cs rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/WithIgnoredBaseAndCustomBase.cs index 447e2f6f..19e0ce52 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/WithIgnoredBaseAndCustomBase.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Entities/WithIgnoredBaseAndCustomBase.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CommonCases.Entities +namespace TypeGen.FileContentTest.CommonCases.Entities { [ExportTsClass] [TsIgnoreBase] diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/array-of-nullable.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/array-of-nullable.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/array-of-nullable.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/array-of-nullable.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/bar.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/bar.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/bar.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/bar.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/base-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/base-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/base-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/base-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/base-class2.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/base-class2.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/base-class2.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/base-class2.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/c.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/c.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/c.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/c.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/custom-base-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/custom-base-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/custom-base-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/custom-base-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/custom-base-custom-import.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/custom-base-custom-import.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/custom-base-custom-import.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/custom-base-custom-import.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/custom-empty-base-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/custom-empty-base-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/custom-empty-base-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/custom-empty-base-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/d.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/d.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/d.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/d.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/default-member-values.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/default-member-values.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/default-member-values.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/default-member-values.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/default-member-values_struct.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/default-member-values_struct.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/default-member-values_struct.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/default-member-values_struct.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/dictionary-string-object-error-case.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/dictionary-string-object-error-case.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/dictionary-string-object-error-case.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/dictionary-string-object-error-case.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/dictionary-with-enum-key.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/dictionary-with-enum-key.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/dictionary-with-enum-key.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/dictionary-with-enum-key.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/e-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/e-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/e-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/e-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/enum-as-union-type.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/enum-as-union-type.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/enum-as-union-type.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/enum-as-union-type.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/enum-short-values.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/enum-short-values.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/enum-short-values.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/enum-short-values.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/extended-primitives-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/extended-primitives-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/extended-primitives-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/extended-primitives-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/external-deps-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/external-deps-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/external-deps-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/external-deps-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/f-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/f-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/f-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/f-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/foo-constants.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/foo-constants.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/foo-constants.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/foo-constants.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/foo-type.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/foo-type.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/foo-type.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/foo-type.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/foo.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/foo.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/foo.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/foo.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/generic-base-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/generic-base-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/generic-base-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/generic-base-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/generic-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/generic-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/generic-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/generic-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/generic-with-restrictions.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/generic-with-restrictions.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/generic-with-restrictions.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/generic-with-restrictions.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/i-test-interface.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/i-test-interface.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/i-test-interface.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/i-test-interface.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/index.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/index.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/index.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/index.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/lite-db-entity.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/lite-db-entity.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/lite-db-entity.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/lite-db-entity.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/no/slash/output/dir/no-slash-output-dir.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/no/slash/output/dir/no-slash-output-dir.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/no/slash/output/dir/no-slash-output-dir.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/no/slash/output/dir/no-slash-output-dir.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/readonly-interface.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/readonly-interface.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/readonly-interface.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/readonly-interface.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/standalone-enum.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/standalone-enum.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/standalone-enum.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/standalone-enum.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/static-readonly.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/static-readonly.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/static-readonly.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/static-readonly.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/strict-nulls-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/strict-nulls-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/strict-nulls-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/strict-nulls-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-classes/base-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-classes/base-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-classes/base-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-classes/base-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-classes/base-class2.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-classes/base-class2.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-classes/base-class2.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-classes/base-class2.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-classes/circular-ref-class1.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-classes/circular-ref-class1.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-classes/circular-ref-class1.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-classes/circular-ref-class1.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-classes/circular-ref-class2.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-classes/circular-ref-class2.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-classes/circular-ref-class2.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-classes/circular-ref-class2.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-classes/test-class.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-classes/test-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-classes/test-class.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-classes/test-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-enums/test-enum.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-enums/test-enum.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-enums/test-enum.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-enums/test-enum.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-interfaces/test-interface.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-interfaces/test-interface.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/test-interfaces/test-interface.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/test-interfaces/test-interface.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/type-unions.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/type-unions.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/type-unions.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/type-unions.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/very/nested/directory/nested-entity.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/very/nested/directory/nested-entity.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/very/nested/directory/nested-entity.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/very/nested/directory/nested-entity.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/with-generic-base-class-custom-type.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/with-generic-base-class-custom-type.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/with-generic-base-class-custom-type.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/with-generic-base-class-custom-type.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/with-ignored-base-and-custom-base.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/with-ignored-base-and-custom-base.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/with-ignored-base-and-custom-base.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/with-ignored-base-and-custom-base.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/with-ignored-base.ts b/src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/with-ignored-base.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CommonCases/Expected/with-ignored-base.ts rename to src/TypeGen/TypeGen.FileContentTest/CommonCases/Expected/with-ignored-base.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/ConstantsOnly/ConstantsOnlyTest.cs b/src/TypeGen/TypeGen.FileContentTest/ConstantsOnly/ConstantsOnlyTest.cs similarity index 77% rename from src/TypeGen/TypeGen.IntegrationTest/ConstantsOnly/ConstantsOnlyTest.cs rename to src/TypeGen/TypeGen.FileContentTest/ConstantsOnly/ConstantsOnlyTest.cs index 1628e900..ccab3b10 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/ConstantsOnly/ConstantsOnlyTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/ConstantsOnly/ConstantsOnlyTest.cs @@ -2,15 +2,15 @@ using System.Threading.Tasks; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.ConstantsOnly; +namespace TypeGen.FileContentTest.ConstantsOnly; public class ConstantsOnlyTest : GenerationTestBase { [Theory] - [InlineData(typeof(Entities.ConstantsOnly), "TypeGen.IntegrationTest.ConstantsOnly.Expected.constants-only.ts")] + [InlineData(typeof(Entities.ConstantsOnly), "TypeGen.FileContentTest.ConstantsOnly.Expected.constants-only.ts")] public async Task TestConstantsOnlyGenerationSpec(Type type, string expectedLocation) { var generationSpec = new ConstantsOnlyGenerationSpec(); diff --git a/src/TypeGen/TypeGen.IntegrationTest/ConstantsOnly/Entities/ConstantsOnly.cs b/src/TypeGen/TypeGen.FileContentTest/ConstantsOnly/Entities/ConstantsOnly.cs similarity index 91% rename from src/TypeGen/TypeGen.IntegrationTest/ConstantsOnly/Entities/ConstantsOnly.cs rename to src/TypeGen/TypeGen.FileContentTest/ConstantsOnly/Entities/ConstantsOnly.cs index 74751787..59bbf2ce 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/ConstantsOnly/Entities/ConstantsOnly.cs +++ b/src/TypeGen/TypeGen.FileContentTest/ConstantsOnly/Entities/ConstantsOnly.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.ConstantsOnly.Entities +namespace TypeGen.FileContentTest.ConstantsOnly.Entities { [ExportTsClass] public class ConstantsOnly diff --git a/src/TypeGen/TypeGen.IntegrationTest/ConstantsOnly/Expected/constants-only.ts b/src/TypeGen/TypeGen.FileContentTest/ConstantsOnly/Expected/constants-only.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/ConstantsOnly/Expected/constants-only.ts rename to src/TypeGen/TypeGen.FileContentTest/ConstantsOnly/Expected/constants-only.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/Converters/JsonMemberNameConverter.cs b/src/TypeGen/TypeGen.FileContentTest/Converters/JsonMemberNameConverter.cs similarity index 89% rename from src/TypeGen/TypeGen.IntegrationTest/Converters/JsonMemberNameConverter.cs rename to src/TypeGen/TypeGen.FileContentTest/Converters/JsonMemberNameConverter.cs index f25efa62..21219302 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Converters/JsonMemberNameConverter.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Converters/JsonMemberNameConverter.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using TypeGen.Core.Converters; -namespace TypeGen.IntegrationTest.Converters +namespace TypeGen.FileContentTest.Converters { public class JsonMemberNameConverter : IMemberNameConverter { diff --git a/src/TypeGen/TypeGen.IntegrationTest/Converters/PascalCaseToCamelCaseJsonConverter.cs b/src/TypeGen/TypeGen.FileContentTest/Converters/PascalCaseToCamelCaseJsonConverter.cs similarity index 91% rename from src/TypeGen/TypeGen.IntegrationTest/Converters/PascalCaseToCamelCaseJsonConverter.cs rename to src/TypeGen/TypeGen.FileContentTest/Converters/PascalCaseToCamelCaseJsonConverter.cs index 99b6fdbc..74442fab 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Converters/PascalCaseToCamelCaseJsonConverter.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Converters/PascalCaseToCamelCaseJsonConverter.cs @@ -2,7 +2,7 @@ using Newtonsoft.Json; using TypeGen.Core.Converters; -namespace TypeGen.IntegrationTest.Converters +namespace TypeGen.FileContentTest.Converters { public class PascalCaseToCamelCaseJsonConverter : IMemberNameConverter { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/CustomBaseInterfacesTest.cs b/src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/CustomBaseInterfacesTest.cs similarity index 81% rename from src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/CustomBaseInterfacesTest.cs rename to src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/CustomBaseInterfacesTest.cs index e3099449..63d81803 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/CustomBaseInterfacesTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/CustomBaseInterfacesTest.cs @@ -3,16 +3,16 @@ using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; using TypeGen.Core.TypeAnnotations; -using TypeGen.IntegrationTest.CustomBaseInterfaces.Entities; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.CustomBaseInterfaces.Entities; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.CustomBaseInterfaces; +namespace TypeGen.FileContentTest.CustomBaseInterfaces; public class CustomBaseInterfacesTest : GenerationTestBase { [Theory] - [InlineData(typeof(Foo), "TypeGen.IntegrationTest.CustomBaseInterfaces.Expected.foo.ts")] + [InlineData(typeof(Foo), "TypeGen.FileContentTest.CustomBaseInterfaces.Expected.foo.ts")] public async Task TestCustomBaseInterfacesGenerationSpec(Type type, string expectedLocation) { var generationSpec = new CustomBaseInterfacesGenerationSpec(); @@ -21,7 +21,7 @@ public async Task TestCustomBaseInterfacesGenerationSpec(Type type, string expec } [Theory] - [InlineData(typeof(Foo), "TypeGen.IntegrationTest.CustomBaseInterfaces.Expected.foo.ts")] + [InlineData(typeof(Foo), "TypeGen.FileContentTest.CustomBaseInterfaces.Expected.foo.ts")] public async Task TestCustomBaseInterfacesFromAssembly(Type type, string expectedLocation) { await TestFromAssembly(type, expectedLocation); diff --git a/src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/Entities/Foo.cs b/src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/Entities/Foo.cs similarity index 78% rename from src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/Entities/Foo.cs rename to src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/Entities/Foo.cs index 609a7dda..d8a9e0d6 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/Entities/Foo.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/Entities/Foo.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.CustomBaseInterfaces.Entities; +namespace TypeGen.FileContentTest.CustomBaseInterfaces.Entities; [ExportTsClass] [TsCustomBase(null, null, null, false, diff --git a/src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/Entities/ITest.cs b/src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/Entities/ITest.cs new file mode 100644 index 00000000..82e9fded --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/Entities/ITest.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.CustomBaseInterfaces.Entities; + +public interface ITest +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/Expected/foo.ts b/src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/Expected/foo.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/Expected/foo.ts rename to src/TypeGen/TypeGen.FileContentTest/CustomBaseInterfaces/Expected/foo.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/CustomMappingsClassGeneration/CustomMappingsClassGeneration.cs b/src/TypeGen/TypeGen.FileContentTest/CustomMappingsClassGeneration/CustomMappingsClassGeneration.cs similarity index 86% rename from src/TypeGen/TypeGen.IntegrationTest/CustomMappingsClassGeneration/CustomMappingsClassGeneration.cs rename to src/TypeGen/TypeGen.FileContentTest/CustomMappingsClassGeneration/CustomMappingsClassGeneration.cs index 7bb211c8..667cffd8 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/CustomMappingsClassGeneration/CustomMappingsClassGeneration.cs +++ b/src/TypeGen/TypeGen.FileContentTest/CustomMappingsClassGeneration/CustomMappingsClassGeneration.cs @@ -3,12 +3,11 @@ using System.Threading.Tasks; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.CommonCases.Entities.CustomMappingsClassGenerationIssue; -using TypeGen.IntegrationTest.Extensions; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.CommonCases.Entities.CustomMappingsClassGenerationIssue; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.CustomMappingsClassGeneration +namespace TypeGen.FileContentTest.CustomMappingsClassGeneration { public class CustomMappingsClassGeneration : GenerationTestBase { @@ -16,7 +15,7 @@ public class CustomMappingsClassGeneration : GenerationTestBase public async Task GeneratesCorrectly() { var type = typeof(ClassWithUri); - var expectedLocation = @"TypeGen.IntegrationTest.CustomMappingsClassGeneration.Expected.class-with-uri.ts"; + var expectedLocation = @"TypeGen.FileContentTest.CustomMappingsClassGeneration.Expected.class-with-uri.ts"; var spec = new TestGenerationSpec(); var generatorOptions = new GeneratorOptions { diff --git a/src/TypeGen/TypeGen.IntegrationTest/CustomMappingsClassGeneration/Expected/class-with-uri.ts b/src/TypeGen/TypeGen.FileContentTest/CustomMappingsClassGeneration/Expected/class-with-uri.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/CustomMappingsClassGeneration/Expected/class-with-uri.ts rename to src/TypeGen/TypeGen.FileContentTest/CustomMappingsClassGeneration/Expected/class-with-uri.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/DefaultExportTest.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/DefaultExportTest.cs similarity index 58% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/DefaultExportTest.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/DefaultExportTest.cs index 15cd7f05..8f85979c 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/DefaultExportTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/DefaultExportTest.cs @@ -1,11 +1,10 @@ using System; using System.Threading.Tasks; -using TypeGen.IntegrationTest.CommonCases; -using TypeGen.IntegrationTest.DefaultExport.Entities; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.DefaultExport.Entities; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.DefaultExport +namespace TypeGen.FileContentTest.DefaultExport { public class DefaultExportTest : GenerationTestBase { @@ -16,19 +15,19 @@ public class DefaultExportTest : GenerationTestBase /// /// [Theory] - [InlineData(typeof(ClassWithDefaultExport), "TypeGen.IntegrationTest.DefaultExport.Expected.class-with-default-export.ts")] - [InlineData(typeof(GenericClassWithDefaultExport<,>), "TypeGen.IntegrationTest.DefaultExport.Expected.generic-class-with-default-export.ts")] - [InlineData(typeof(ClassWithImports), "TypeGen.IntegrationTest.DefaultExport.Expected.class-with-imports.ts")] - [InlineData(typeof(ClassWithoutDefaultExport), "TypeGen.IntegrationTest.DefaultExport.Expected.class-without-default-export.ts")] - [InlineData(typeof(InterfaceWithDefaultExport), "TypeGen.IntegrationTest.DefaultExport.Expected.interface-with-default-export.ts")] + [InlineData(typeof(ClassWithDefaultExport), "TypeGen.FileContentTest.DefaultExport.Expected.class-with-default-export.ts")] + [InlineData(typeof(GenericClassWithDefaultExport<,>), "TypeGen.FileContentTest.DefaultExport.Expected.generic-class-with-default-export.ts")] + [InlineData(typeof(ClassWithImports), "TypeGen.FileContentTest.DefaultExport.Expected.class-with-imports.ts")] + [InlineData(typeof(ClassWithoutDefaultExport), "TypeGen.FileContentTest.DefaultExport.Expected.class-without-default-export.ts")] + [InlineData(typeof(InterfaceWithDefaultExport), "TypeGen.FileContentTest.DefaultExport.Expected.interface-with-default-export.ts")] // structs - [InlineData(typeof(DefaultExport.Entities.Structs.ClassWithDefaultExport), "TypeGen.IntegrationTest.DefaultExport.Expected.class-with-default-export.ts")] - [InlineData(typeof(DefaultExport.Entities.Structs.GenericClassWithDefaultExport<,>), "TypeGen.IntegrationTest.DefaultExport.Expected.generic-class-with-default-export.ts")] - [InlineData(typeof(DefaultExport.Entities.Structs.ClassWithImports), "TypeGen.IntegrationTest.DefaultExport.Expected.class-with-imports.ts")] - [InlineData(typeof(DefaultExport.Entities.Structs.ClassWithoutDefaultExport), "TypeGen.IntegrationTest.DefaultExport.Expected.class-without-default-export.ts")] - [InlineData(typeof(DefaultExport.Entities.Structs.InterfaceWithDefaultExport), "TypeGen.IntegrationTest.DefaultExport.Expected.interface-with-default-export.ts")] + [InlineData(typeof(DefaultExport.Entities.Structs.ClassWithDefaultExport), "TypeGen.FileContentTest.DefaultExport.Expected.class-with-default-export.ts")] + [InlineData(typeof(DefaultExport.Entities.Structs.GenericClassWithDefaultExport<,>), "TypeGen.FileContentTest.DefaultExport.Expected.generic-class-with-default-export.ts")] + [InlineData(typeof(DefaultExport.Entities.Structs.ClassWithImports), "TypeGen.FileContentTest.DefaultExport.Expected.class-with-imports.ts")] + [InlineData(typeof(DefaultExport.Entities.Structs.ClassWithoutDefaultExport), "TypeGen.FileContentTest.DefaultExport.Expected.class-without-default-export.ts")] + [InlineData(typeof(DefaultExport.Entities.Structs.InterfaceWithDefaultExport), "TypeGen.FileContentTest.DefaultExport.Expected.interface-with-default-export.ts")] public async Task GeneratesCorrectly(Type type, string expectedLocation) { await TestFromAssembly(type, expectedLocation); diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/ClassWithDefaultExport.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/ClassWithDefaultExport.cs similarity index 75% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/ClassWithDefaultExport.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/ClassWithDefaultExport.cs index e2658bb2..8782573a 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/ClassWithDefaultExport.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/ClassWithDefaultExport.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.DefaultExport.Entities +namespace TypeGen.FileContentTest.DefaultExport.Entities { [ExportTsClass(OutputDir = "default-export/")] [TsDefaultExport] diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/ClassWithImports.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/ClassWithImports.cs similarity index 92% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/ClassWithImports.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/ClassWithImports.cs index eb6538ca..0da9a326 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/ClassWithImports.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/ClassWithImports.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.DefaultExport.Entities +namespace TypeGen.FileContentTest.DefaultExport.Entities { [ExportTsClass(OutputDir = "default-export/")] [TsCustomBase("BaseWithDefaultExport", "./my-path/example/base", isDefaultExport: true)] diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/ClassWithoutDefaultExport.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/ClassWithoutDefaultExport.cs similarity index 73% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/ClassWithoutDefaultExport.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/ClassWithoutDefaultExport.cs index 763fea07..237a93ed 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/ClassWithoutDefaultExport.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/ClassWithoutDefaultExport.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.DefaultExport.Entities +namespace TypeGen.FileContentTest.DefaultExport.Entities { [ExportTsClass(OutputDir = "default-export/")] public class ClassWithoutDefaultExport diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/GenericClassWithDefaultExport.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/GenericClassWithDefaultExport.cs similarity index 76% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/GenericClassWithDefaultExport.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/GenericClassWithDefaultExport.cs index 0307e99a..dab876e5 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/GenericClassWithDefaultExport.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/GenericClassWithDefaultExport.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.DefaultExport.Entities +namespace TypeGen.FileContentTest.DefaultExport.Entities { [ExportTsClass(OutputDir = "default-export")] [TsDefaultExport] diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/InterfaceWithDefaultExport.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/InterfaceWithDefaultExport.cs similarity index 76% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/InterfaceWithDefaultExport.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/InterfaceWithDefaultExport.cs index f2900b65..9fc84f5c 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/InterfaceWithDefaultExport.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/InterfaceWithDefaultExport.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.DefaultExport.Entities +namespace TypeGen.FileContentTest.DefaultExport.Entities { [ExportTsInterface(OutputDir = "default-export/")] [TsDefaultExport] diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/ClassWithDefaultExport.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/ClassWithDefaultExport.cs similarity index 73% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/ClassWithDefaultExport.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/ClassWithDefaultExport.cs index a8adda97..1a64d527 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/ClassWithDefaultExport.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/ClassWithDefaultExport.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.DefaultExport.Entities.Structs +namespace TypeGen.FileContentTest.DefaultExport.Entities.Structs { [ExportTsClass(OutputDir = "default-export/")] [TsDefaultExport] diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/ClassWithImports.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/ClassWithImports.cs similarity index 91% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/ClassWithImports.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/ClassWithImports.cs index 4271c316..a00d9a81 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/ClassWithImports.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/ClassWithImports.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.DefaultExport.Entities.Structs +namespace TypeGen.FileContentTest.DefaultExport.Entities.Structs { [ExportTsClass(OutputDir = "default-export/")] [TsCustomBase("BaseWithDefaultExport", "./my-path/example/base", isDefaultExport: true)] diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/ClassWithoutDefaultExport.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/ClassWithoutDefaultExport.cs similarity index 71% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/ClassWithoutDefaultExport.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/ClassWithoutDefaultExport.cs index d90fd135..520c5b81 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/ClassWithoutDefaultExport.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/ClassWithoutDefaultExport.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.DefaultExport.Entities.Structs +namespace TypeGen.FileContentTest.DefaultExport.Entities.Structs { [ExportTsClass(OutputDir = "default-export/")] public struct ClassWithoutDefaultExport diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/GenericClassWithDefaultExport.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/GenericClassWithDefaultExport.cs similarity index 74% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/GenericClassWithDefaultExport.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/GenericClassWithDefaultExport.cs index e7cc43bc..0cc69ef6 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/GenericClassWithDefaultExport.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/GenericClassWithDefaultExport.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.DefaultExport.Entities.Structs +namespace TypeGen.FileContentTest.DefaultExport.Entities.Structs { [ExportTsClass(OutputDir = "default-export")] [TsDefaultExport] diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/InterfaceWithDefaultExport.cs b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/InterfaceWithDefaultExport.cs similarity index 74% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/InterfaceWithDefaultExport.cs rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/InterfaceWithDefaultExport.cs index 0c83eed3..17dd6775 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Entities/Structs/InterfaceWithDefaultExport.cs +++ b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Entities/Structs/InterfaceWithDefaultExport.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.DefaultExport.Entities.Structs +namespace TypeGen.FileContentTest.DefaultExport.Entities.Structs { [ExportTsInterface(OutputDir = "default-export/")] [TsDefaultExport] diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Expected/class-with-default-export.ts b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Expected/class-with-default-export.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Expected/class-with-default-export.ts rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Expected/class-with-default-export.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Expected/class-with-imports.ts b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Expected/class-with-imports.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Expected/class-with-imports.ts rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Expected/class-with-imports.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Expected/class-without-default-export.ts b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Expected/class-without-default-export.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Expected/class-without-default-export.ts rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Expected/class-without-default-export.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Expected/generic-class-with-default-export.ts b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Expected/generic-class-with-default-export.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Expected/generic-class-with-default-export.ts rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Expected/generic-class-with-default-export.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Expected/interface-with-default-export.ts b/src/TypeGen/TypeGen.FileContentTest/DefaultExport/Expected/interface-with-default-export.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/DefaultExport/Expected/interface-with-default-export.ts rename to src/TypeGen/TypeGen.FileContentTest/DefaultExport/Expected/interface-with-default-export.ts diff --git a/src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Entities/Child.cs b/src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Entities/Child.cs new file mode 100644 index 00000000..5f3f50ea --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Entities/Child.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.ExportTypesAsInterfacesByDefault.Entities; + +public class Child +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Entities/Parent.cs b/src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Entities/Parent.cs similarity index 52% rename from src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Entities/Parent.cs rename to src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Entities/Parent.cs index d3b6e8cd..9d07a19d 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Entities/Parent.cs +++ b/src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Entities/Parent.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.ExportTypesAsInterfacesByDefault.Entities; +namespace TypeGen.FileContentTest.ExportTypesAsInterfacesByDefault.Entities; public class Parent { diff --git a/src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Expected/child-as-class.ts b/src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Expected/child-as-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Expected/child-as-class.ts rename to src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Expected/child-as-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Expected/child-as-interface.ts b/src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Expected/child-as-interface.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Expected/child-as-interface.ts rename to src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/Expected/child-as-interface.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/ExportTypesAsInterfacesByDefaultTest.cs b/src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/ExportTypesAsInterfacesByDefaultTest.cs similarity index 81% rename from src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/ExportTypesAsInterfacesByDefaultTest.cs rename to src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/ExportTypesAsInterfacesByDefaultTest.cs index d007f8f4..33d3c707 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/ExportTypesAsInterfacesByDefaultTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/ExportTypesAsInterfacesByDefault/ExportTypesAsInterfacesByDefaultTest.cs @@ -1,11 +1,11 @@ using System.Threading.Tasks; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.ExportTypesAsInterfacesByDefault.Entities; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.ExportTypesAsInterfacesByDefault.Entities; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.ExportTypesAsInterfacesByDefault; +namespace TypeGen.FileContentTest.ExportTypesAsInterfacesByDefault; public class ExportTypesAsInterfacesByDefaultTest : GenerationTestBase { @@ -13,7 +13,7 @@ public class ExportTypesAsInterfacesByDefaultTest : GenerationTestBase public async Task if_option_not_set_should_generate_class() { var type = typeof(Child); - const string expectedLocation = "TypeGen.IntegrationTest.ExportTypesAsInterfacesByDefault.Expected.child-as-class.ts"; + const string expectedLocation = "TypeGen.FileContentTest.ExportTypesAsInterfacesByDefault.Expected.child-as-class.ts"; var generatorOptions = new GeneratorOptions(); var generationSpec = new ExportTypesAsInterfacesByDefaultGenerationSpec(); await TestGenerationSpec(type, expectedLocation, generationSpec, generatorOptions); @@ -23,7 +23,7 @@ public async Task if_option_not_set_should_generate_class() public async Task if_option_set_should_generate_interface() { var type = typeof(Child); - const string expectedLocation = "TypeGen.IntegrationTest.ExportTypesAsInterfacesByDefault.Expected.child-as-interface.ts"; + const string expectedLocation = "TypeGen.FileContentTest.ExportTypesAsInterfacesByDefault.Expected.child-as-interface.ts"; var generatorOptions = new GeneratorOptions { ExportTypesAsInterfacesByDefault = true }; var generationSpec = new ExportTypesAsInterfacesByDefaultGenerationSpec(); await TestGenerationSpec(type, expectedLocation, generationSpec, generatorOptions); diff --git a/src/TypeGen/TypeGen.IntegrationTest/Extensions/StringExtensions.cs b/src/TypeGen/TypeGen.FileContentTest/Extensions/StringExtensions.cs similarity index 85% rename from src/TypeGen/TypeGen.IntegrationTest/Extensions/StringExtensions.cs rename to src/TypeGen/TypeGen.FileContentTest/Extensions/StringExtensions.cs index 5b9f5529..32fa03b8 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/Extensions/StringExtensions.cs +++ b/src/TypeGen/TypeGen.FileContentTest/Extensions/StringExtensions.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.Extensions; +namespace TypeGen.FileContentTest.Extensions; public static class StringExtensions { diff --git a/src/TypeGen/TypeGen.IntegrationTest/GenerationSpecForStructs/GenerationSpecsForStructsTest.cs b/src/TypeGen/TypeGen.FileContentTest/GenerationSpecForStructs/GenerationSpecsForStructsTest.cs similarity index 68% rename from src/TypeGen/TypeGen.IntegrationTest/GenerationSpecForStructs/GenerationSpecsForStructsTest.cs rename to src/TypeGen/TypeGen.FileContentTest/GenerationSpecForStructs/GenerationSpecsForStructsTest.cs index 7cb46e9b..cd54bbf4 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/GenerationSpecForStructs/GenerationSpecsForStructsTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/GenerationSpecForStructs/GenerationSpecsForStructsTest.cs @@ -2,21 +2,21 @@ using System.Threading.Tasks; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.CommonCases.Entities.Structs; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.CommonCases.Entities.Structs; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.GenerationSpecForStructs; +namespace TypeGen.FileContentTest.GenerationSpecForStructs; public class GenerationSpecsForStructsTest : GenerationTestBase { [Theory] - [InlineData(typeof(CustomBaseClass), "TypeGen.IntegrationTest.CommonCases.Expected.custom-base-class.ts")] - [InlineData(typeof(CustomBaseCustomImport), "TypeGen.IntegrationTest.CommonCases.Expected.custom-base-custom-import.ts")] - [InlineData(typeof(CustomEmptyBaseClass), "TypeGen.IntegrationTest.CommonCases.Expected.custom-empty-base-class.ts")] - [InlineData(typeof(ExtendedPrimitivesClass), "TypeGen.IntegrationTest.CommonCases.Expected.extended-primitives-class.ts")] - [InlineData(typeof(ExternalDepsClass), "TypeGen.IntegrationTest.CommonCases.Expected.external-deps-class.ts")] - [InlineData(typeof(GenericBaseClass<>), "TypeGen.IntegrationTest.CommonCases.Expected.generic-base-class.ts")] + [InlineData(typeof(CustomBaseClass), "TypeGen.FileContentTest.CommonCases.Expected.custom-base-class.ts")] + [InlineData(typeof(CustomBaseCustomImport), "TypeGen.FileContentTest.CommonCases.Expected.custom-base-custom-import.ts")] + [InlineData(typeof(CustomEmptyBaseClass), "TypeGen.FileContentTest.CommonCases.Expected.custom-empty-base-class.ts")] + [InlineData(typeof(ExtendedPrimitivesClass), "TypeGen.FileContentTest.CommonCases.Expected.extended-primitives-class.ts")] + [InlineData(typeof(ExternalDepsClass), "TypeGen.FileContentTest.CommonCases.Expected.external-deps-class.ts")] + [InlineData(typeof(GenericBaseClass<>), "TypeGen.FileContentTest.CommonCases.Expected.generic-base-class.ts")] public async Task TestGenerationSpecForStructs(Type type, string expectedLocation) { var generationSpec = new StructsGenerationSpec(); diff --git a/src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/Entities/ITest.cs b/src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/Entities/ITest.cs new file mode 100644 index 00000000..63ae6ca3 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/Entities/ITest.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.IgnoreBaseInterfaces.Entities; + +public interface ITest +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/Entities/Test.cs b/src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/Entities/Test.cs similarity index 68% rename from src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/Entities/Test.cs rename to src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/Entities/Test.cs index 2450dbbd..0112a8cf 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/Entities/Test.cs +++ b/src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/Entities/Test.cs @@ -1,6 +1,6 @@ using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.IgnoreBaseInterfaces.Entities; +namespace TypeGen.FileContentTest.IgnoreBaseInterfaces.Entities; [ExportTsClass] [TsIgnoreBase] diff --git a/src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/Expected/test.ts b/src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/Expected/test.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/Expected/test.ts rename to src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/Expected/test.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/IgnoreBaseInterfacesTest.cs b/src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/IgnoreBaseInterfacesTest.cs similarity index 58% rename from src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/IgnoreBaseInterfacesTest.cs rename to src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/IgnoreBaseInterfacesTest.cs index 345c324d..998b26e5 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/IgnoreBaseInterfacesTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/IgnoreBaseInterfaces/IgnoreBaseInterfacesTest.cs @@ -1,15 +1,15 @@ using System; using System.Threading.Tasks; -using TypeGen.IntegrationTest.IgnoreBaseInterfaces.Entities; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.IgnoreBaseInterfaces.Entities; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.IgnoreBaseInterfaces; +namespace TypeGen.FileContentTest.IgnoreBaseInterfaces; public class IgnoreBaseInterfacesTest : GenerationTestBase { [Theory] - [InlineData(typeof(Test), "TypeGen.IntegrationTest.IgnoreBaseInterfaces.Expected.test.ts")] + [InlineData(typeof(Test), "TypeGen.FileContentTest.IgnoreBaseInterfaces.Expected.test.ts")] public async Task TestIgnoreBaseInterfaces(Type type, string expectedLocation) { await TestFromAssembly(type, expectedLocation); diff --git a/src/TypeGen/TypeGen.FileContentTest/ImportType/Entities/DepClass.cs b/src/TypeGen/TypeGen.FileContentTest/ImportType/Entities/DepClass.cs new file mode 100644 index 00000000..78efd327 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/ImportType/Entities/DepClass.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.ImportType.Entities; + +public class DepClass +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/ImportType/Entities/TsClass.cs b/src/TypeGen/TypeGen.FileContentTest/ImportType/Entities/TsClass.cs similarity index 53% rename from src/TypeGen/TypeGen.IntegrationTest/ImportType/Entities/TsClass.cs rename to src/TypeGen/TypeGen.FileContentTest/ImportType/Entities/TsClass.cs index 00a0435b..e77fb07f 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/ImportType/Entities/TsClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/ImportType/Entities/TsClass.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.ImportType.Entities; +namespace TypeGen.FileContentTest.ImportType.Entities; public class TsClass { diff --git a/src/TypeGen/TypeGen.IntegrationTest/ImportType/Expected/ts-class-default-export.ts b/src/TypeGen/TypeGen.FileContentTest/ImportType/Expected/ts-class-default-export.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/ImportType/Expected/ts-class-default-export.ts rename to src/TypeGen/TypeGen.FileContentTest/ImportType/Expected/ts-class-default-export.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/ImportType/Expected/ts-class.ts b/src/TypeGen/TypeGen.FileContentTest/ImportType/Expected/ts-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/ImportType/Expected/ts-class.ts rename to src/TypeGen/TypeGen.FileContentTest/ImportType/Expected/ts-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/ImportType/ImportTypeTest.cs b/src/TypeGen/TypeGen.FileContentTest/ImportType/ImportTypeTest.cs similarity index 71% rename from src/TypeGen/TypeGen.IntegrationTest/ImportType/ImportTypeTest.cs rename to src/TypeGen/TypeGen.FileContentTest/ImportType/ImportTypeTest.cs index 5e934f08..e21bab14 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/ImportType/ImportTypeTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/ImportType/ImportTypeTest.cs @@ -2,18 +2,17 @@ using System.Threading.Tasks; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.IgnoreBaseInterfaces.Entities; -using TypeGen.IntegrationTest.ImportType.Entities; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.ImportType.Entities; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.ImportType; +namespace TypeGen.FileContentTest.ImportType; public class ImportTypeTest : GenerationTestBase { [Theory] - [InlineData(typeof(TsClass), "TypeGen.IntegrationTest.ImportType.Expected.ts-class.ts", false)] - [InlineData(typeof(TsClass), "TypeGen.IntegrationTest.ImportType.Expected.ts-class-default-export.ts", true)] + [InlineData(typeof(TsClass), "TypeGen.FileContentTest.ImportType.Expected.ts-class.ts", false)] + [InlineData(typeof(TsClass), "TypeGen.FileContentTest.ImportType.Expected.ts-class-default-export.ts", true)] public async Task TestImportType(Type type, string expectedLocation, bool useDefaultExport) { var generationSpec = new ImportTypeGenerationSpec(); diff --git a/src/TypeGen/TypeGen.IntegrationTest/NullableTranslation/Entities/NullableClass.cs b/src/TypeGen/TypeGen.FileContentTest/NullableTranslation/Entities/NullableClass.cs similarity index 92% rename from src/TypeGen/TypeGen.IntegrationTest/NullableTranslation/Entities/NullableClass.cs rename to src/TypeGen/TypeGen.FileContentTest/NullableTranslation/Entities/NullableClass.cs index c449332d..d48c1c2e 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/NullableTranslation/Entities/NullableClass.cs +++ b/src/TypeGen/TypeGen.FileContentTest/NullableTranslation/Entities/NullableClass.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using TypeGen.Core.TypeAnnotations; -namespace TypeGen.IntegrationTest.NullableTranslation.Entities +namespace TypeGen.FileContentTest.NullableTranslation.Entities { [ExportTsClass] public class NullableClass diff --git a/src/TypeGen/TypeGen.IntegrationTest/NullableTranslation/Expected/nullable-class.ts b/src/TypeGen/TypeGen.FileContentTest/NullableTranslation/Expected/nullable-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/NullableTranslation/Expected/nullable-class.ts rename to src/TypeGen/TypeGen.FileContentTest/NullableTranslation/Expected/nullable-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/NullableTranslation/NullableTranslationTest.cs b/src/TypeGen/TypeGen.FileContentTest/NullableTranslation/NullableTranslationTest.cs similarity index 79% rename from src/TypeGen/TypeGen.IntegrationTest/NullableTranslation/NullableTranslationTest.cs rename to src/TypeGen/TypeGen.FileContentTest/NullableTranslation/NullableTranslationTest.cs index 7c18f3c9..9bb5850b 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/NullableTranslation/NullableTranslationTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/NullableTranslation/NullableTranslationTest.cs @@ -3,16 +3,16 @@ using TypeGen.Core; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.NullableTranslation.Entities; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.NullableTranslation.Entities; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.NullableTranslation; +namespace TypeGen.FileContentTest.NullableTranslation; public class NullableTranslationTest : GenerationTestBase { [Theory] - [InlineData(typeof(NullableClass), "TypeGen.IntegrationTest.NullableTranslation.Expected.nullable-class.ts")] + [InlineData(typeof(NullableClass), "TypeGen.FileContentTest.NullableTranslation.Expected.nullable-class.ts")] public async Task TestNullableTranslationGenerationSpec(Type type, string expectedLocation) { var generationSpec = new NullableTranslationGenerationSpec(); diff --git a/src/TypeGen/TypeGen.FileContentTest/StructImplementsInterfaces/Entities/ImplementsInterfaces.cs b/src/TypeGen/TypeGen.FileContentTest/StructImplementsInterfaces/Entities/ImplementsInterfaces.cs new file mode 100644 index 00000000..0287470e --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/StructImplementsInterfaces/Entities/ImplementsInterfaces.cs @@ -0,0 +1,10 @@ +using TypeGen.Core.TypeAnnotations; +using TypeGen.FileContentTest.CommonCases.Entities.Structs; + +namespace TypeGen.FileContentTest.StructImplementsInterfaces.Entities; + +[ExportTsClass] +public struct ImplementsInterfaces : IFoo, IBar +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/StructImplementsInterfaces/Expected/implements-interfaces.ts b/src/TypeGen/TypeGen.FileContentTest/StructImplementsInterfaces/Expected/implements-interfaces.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/StructImplementsInterfaces/Expected/implements-interfaces.ts rename to src/TypeGen/TypeGen.FileContentTest/StructImplementsInterfaces/Expected/implements-interfaces.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/StructImplementsInterfaces/StructImplementsInterfacesTest.cs b/src/TypeGen/TypeGen.FileContentTest/StructImplementsInterfaces/StructImplementsInterfacesTest.cs similarity index 61% rename from src/TypeGen/TypeGen.IntegrationTest/StructImplementsInterfaces/StructImplementsInterfacesTest.cs rename to src/TypeGen/TypeGen.FileContentTest/StructImplementsInterfaces/StructImplementsInterfacesTest.cs index 7848f5e9..b63da5d7 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/StructImplementsInterfaces/StructImplementsInterfacesTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/StructImplementsInterfaces/StructImplementsInterfacesTest.cs @@ -1,21 +1,17 @@ using System; using System.Threading.Tasks; -using TypeGen.Core; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.Core.TypeAnnotations; -using TypeGen.IntegrationTest.CommonCases.Entities.Structs; -using TypeGen.IntegrationTest.NullableTranslation.Entities; -using TypeGen.IntegrationTest.StructImplementsInterfaces.Entities; -using TypeGen.IntegrationTest.TestingUtils; +using TypeGen.FileContentTest.StructImplementsInterfaces.Entities; +using TypeGen.FileContentTest.TestingUtils; using Xunit; -namespace TypeGen.IntegrationTest.StructImplementsInterfaces; +namespace TypeGen.FileContentTest.StructImplementsInterfaces; public class StructImplementsInterfacesTest : GenerationTestBase { [Theory] - [InlineData(typeof(ImplementsInterfaces), "TypeGen.IntegrationTest.StructImplementsInterfaces.Expected.implements-interfaces.ts")] + [InlineData(typeof(ImplementsInterfaces), "TypeGen.FileContentTest.StructImplementsInterfaces.Expected.implements-interfaces.ts")] public async Task TestStructImplementsInterfacesFromGenerationSpec(Type type, string expectedLocation) { var generationSpec = new StructImplementsInterfacesGenerationSpec(); @@ -24,7 +20,7 @@ public async Task TestStructImplementsInterfacesFromGenerationSpec(Type type, st } [Theory] - [InlineData(typeof(ImplementsInterfaces), "TypeGen.IntegrationTest.StructImplementsInterfaces.Expected.implements-interfaces.ts")] + [InlineData(typeof(ImplementsInterfaces), "TypeGen.FileContentTest.StructImplementsInterfaces.Expected.implements-interfaces.ts")] public async Task TestStructImplementsInterfacesFromAssembly(Type type, string expectedLocation) { await TestFromAssembly(type, expectedLocation); diff --git a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/EmbededResourceReader.cs b/src/TypeGen/TypeGen.FileContentTest/TestingUtils/EmbededResourceReader.cs similarity index 89% rename from src/TypeGen/TypeGen.IntegrationTest/TestingUtils/EmbededResourceReader.cs rename to src/TypeGen/TypeGen.FileContentTest/TestingUtils/EmbededResourceReader.cs index bff8703a..11b62c00 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/EmbededResourceReader.cs +++ b/src/TypeGen/TypeGen.FileContentTest/TestingUtils/EmbededResourceReader.cs @@ -1,11 +1,10 @@ -using System.IO; +using System; using System.Reflection; using System.Text; using System.Threading.Tasks; using TypeGen.Core; -using System; -namespace TypeGen.IntegrationTest.TestingUtils +namespace TypeGen.FileContentTest.TestingUtils { public static class EmbededResourceReader { diff --git a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GeneratedOutput.cs b/src/TypeGen/TypeGen.FileContentTest/TestingUtils/GeneratedOutput.cs similarity index 95% rename from src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GeneratedOutput.cs rename to src/TypeGen/TypeGen.FileContentTest/TestingUtils/GeneratedOutput.cs index c98bbebb..3a6443e9 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GeneratedOutput.cs +++ b/src/TypeGen/TypeGen.FileContentTest/TestingUtils/GeneratedOutput.cs @@ -1,7 +1,7 @@ using System; using Gen = TypeGen.Core.Generator; -namespace TypeGen.IntegrationTest.TestingUtils +namespace TypeGen.FileContentTest.TestingUtils { public class GeneratedOutput { diff --git a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs b/src/TypeGen/TypeGen.FileContentTest/TestingUtils/GenerationTestBase.cs similarity index 93% rename from src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs rename to src/TypeGen/TypeGen.FileContentTest/TestingUtils/GenerationTestBase.cs index c1480b38..27dee9eb 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GenerationTestBase.cs +++ b/src/TypeGen/TypeGen.FileContentTest/TestingUtils/GenerationTestBase.cs @@ -3,10 +3,9 @@ using FluentAssertions; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.Extensions; -using Xunit; +using TypeGen.FileContentTest.Extensions; -namespace TypeGen.IntegrationTest.TestingUtils; +namespace TypeGen.FileContentTest.TestingUtils; public class GenerationTestBase { diff --git a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GeneratorOutputInterceptor.cs b/src/TypeGen/TypeGen.FileContentTest/TestingUtils/GeneratorOutputInterceptor.cs similarity index 97% rename from src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GeneratorOutputInterceptor.cs rename to src/TypeGen/TypeGen.FileContentTest/TestingUtils/GeneratorOutputInterceptor.cs index cf021b1b..ecfb2d20 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TestingUtils/GeneratorOutputInterceptor.cs +++ b/src/TypeGen/TypeGen.FileContentTest/TestingUtils/GeneratorOutputInterceptor.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using Gen = TypeGen.Core.Generator; -namespace TypeGen.IntegrationTest.TestingUtils +namespace TypeGen.FileContentTest.TestingUtils { /// /// Intercepts the output produced by the diff --git a/src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/Entities/TsClass.cs b/src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/Entities/TsClass.cs new file mode 100644 index 00000000..ed983e97 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/Entities/TsClass.cs @@ -0,0 +1,5 @@ +namespace TypeGen.FileContentTest.TsClassExtendsTsInterface.Entities; + +public class TsClass : TsInterface +{ +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/Entities/TsInterface.cs b/src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/Entities/TsInterface.cs new file mode 100644 index 00000000..9f47925a --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/Entities/TsInterface.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.TsClassExtendsTsInterface.Entities; + +public class TsInterface +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Expected/ts-class.ts b/src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/Expected/ts-class.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Expected/ts-class.ts rename to src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/Expected/ts-class.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs b/src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs similarity index 77% rename from src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs rename to src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs index caaa4394..bb3400f1 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/TsClassExtendsTsInterface/TsClassExtendsTsInterfaceTest.cs @@ -1,11 +1,11 @@ using System.Threading.Tasks; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.TestingUtils; -using TypeGen.IntegrationTest.TsClassExtendsTsInterface.Entities; +using TypeGen.FileContentTest.TestingUtils; +using TypeGen.FileContentTest.TsClassExtendsTsInterface.Entities; using Xunit; -namespace TypeGen.IntegrationTest.TsClassExtendsTsInterface; +namespace TypeGen.FileContentTest.TsClassExtendsTsInterface; public class TsClassExtendsTsInterfaceTest : GenerationTestBase { @@ -13,7 +13,7 @@ public class TsClassExtendsTsInterfaceTest : GenerationTestBase public async Task TsClassExtendsTsInterface_Test() { var type = typeof(TsClass); - const string expectedLocation = "TypeGen.IntegrationTest.TsClassExtendsTsInterface.Expected.ts-class.ts"; + const string expectedLocation = "TypeGen.FileContentTest.TsClassExtendsTsInterface.Expected.ts-class.ts"; var generationSpec = new TsClassExtendsTsInterfaceGenerationSpec(); var generatorOptions = new GeneratorOptions(); diff --git a/src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/Entities/Base.cs b/src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/Entities/Base.cs new file mode 100644 index 00000000..afd03802 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/Entities/Base.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.TsInterfaceInheritance.Entities; + +public class Base +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/Entities/Sub.cs b/src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/Entities/Sub.cs new file mode 100644 index 00000000..e4b86907 --- /dev/null +++ b/src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/Entities/Sub.cs @@ -0,0 +1,6 @@ +namespace TypeGen.FileContentTest.TsInterfaceInheritance.Entities; + +public class Sub : Base +{ + +} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Expected/sub.ts b/src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/Expected/sub.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Expected/sub.ts rename to src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/Expected/sub.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs b/src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs similarity index 78% rename from src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs rename to src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs index e6d33d34..0a898080 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/TsInterfaceInheritance/TsInterfaceInheritanceTest.cs @@ -1,11 +1,11 @@ using System.Threading.Tasks; using TypeGen.Core.Generator; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.TestingUtils; -using TypeGen.IntegrationTest.TsInterfaceInheritance.Entities; +using TypeGen.FileContentTest.TestingUtils; +using TypeGen.FileContentTest.TsInterfaceInheritance.Entities; using Xunit; -namespace TypeGen.IntegrationTest.TsInterfaceInheritance; +namespace TypeGen.FileContentTest.TsInterfaceInheritance; public class TsInterfaceInheritanceTest : GenerationTestBase { @@ -13,7 +13,7 @@ public class TsInterfaceInheritanceTest : GenerationTestBase public async Task cs_classes_which_are_ts_interfaces_should_respect_ts_interface_inheritance() { var type = typeof(Sub); - const string expectedLocation = "TypeGen.IntegrationTest.TsInterfaceInheritance.Expected.sub.ts"; + const string expectedLocation = "TypeGen.FileContentTest.TsInterfaceInheritance.Expected.sub.ts"; var generationSpec = new TsInterfaceInheritanceGenerationSpec(); var generatorOptions = new GeneratorOptions(); diff --git a/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj b/src/TypeGen/TypeGen.FileContentTest/TypeGen.FileContentTest.csproj similarity index 98% rename from src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj rename to src/TypeGen/TypeGen.FileContentTest/TypeGen.FileContentTest.csproj index f7e07b58..6719fe62 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/TypeGen.IntegrationTest.csproj +++ b/src/TypeGen/TypeGen.FileContentTest/TypeGen.FileContentTest.csproj @@ -5,11 +5,11 @@ false - TypeGen.IntegrationTest + TypeGen.FileContentTest - bin\Debug\TypeGen.IntegrationTest.xml + bin\Debug\TypeGen.FileContentTest.xml diff --git a/src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IId.cs b/src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IId.cs similarity index 53% rename from src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IId.cs rename to src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IId.cs index 0a9f7f27..5b98bd2f 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IId.cs +++ b/src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IId.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.UseDefaultExportBreaksInterfaceInheritance.Entities; +namespace TypeGen.FileContentTest.UseDefaultExportBreaksInterfaceInheritance.Entities; public interface IId { diff --git a/src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IIdentifier.cs b/src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IIdentifier.cs similarity index 58% rename from src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IIdentifier.cs rename to src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IIdentifier.cs index 596222d1..09ddedef 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IIdentifier.cs +++ b/src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Entities/IIdentifier.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.UseDefaultExportBreaksInterfaceInheritance.Entities; +namespace TypeGen.FileContentTest.UseDefaultExportBreaksInterfaceInheritance.Entities; public interface IIdentifier { diff --git a/src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Entities/ProductDto.cs b/src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Entities/ProductDto.cs similarity index 69% rename from src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Entities/ProductDto.cs rename to src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Entities/ProductDto.cs index dd3c50a5..aab7ddfb 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Entities/ProductDto.cs +++ b/src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Entities/ProductDto.cs @@ -1,4 +1,4 @@ -namespace TypeGen.IntegrationTest.UseDefaultExportBreaksInterfaceInheritance.Entities; +namespace TypeGen.FileContentTest.UseDefaultExportBreaksInterfaceInheritance.Entities; public class ProductDto : IId, IIdentifier { diff --git a/src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Expected/product-dto.ts b/src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Expected/product-dto.ts similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/Expected/product-dto.ts rename to src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/Expected/product-dto.ts diff --git a/src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/UseDefaultExportBreaksInterfaceInheritanceTest.cs b/src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/UseDefaultExportBreaksInterfaceInheritanceTest.cs similarity index 81% rename from src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/UseDefaultExportBreaksInterfaceInheritanceTest.cs rename to src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/UseDefaultExportBreaksInterfaceInheritanceTest.cs index 3169682b..b3ad0a36 100644 --- a/src/TypeGen/TypeGen.IntegrationTest/UseDefaultExportBreaksInterfaceInheritance/UseDefaultExportBreaksInterfaceInheritanceTest.cs +++ b/src/TypeGen/TypeGen.FileContentTest/UseDefaultExportBreaksInterfaceInheritance/UseDefaultExportBreaksInterfaceInheritanceTest.cs @@ -1,16 +1,16 @@ using System; using System.Threading.Tasks; using TypeGen.Core.SpecGeneration; -using TypeGen.IntegrationTest.TestingUtils; -using TypeGen.IntegrationTest.UseDefaultExportBreaksInterfaceInheritance.Entities; +using TypeGen.FileContentTest.TestingUtils; +using TypeGen.FileContentTest.UseDefaultExportBreaksInterfaceInheritance.Entities; using Xunit; -namespace TypeGen.IntegrationTest.UseDefaultExportBreaksInterfaceInheritance; +namespace TypeGen.FileContentTest.UseDefaultExportBreaksInterfaceInheritance; public class UseDefaultExportBreaksInterfaceInheritanceTest : GenerationTestBase { [Theory] - [InlineData(typeof(ProductDto), "TypeGen.IntegrationTest.UseDefaultExportBreaksInterfaceInheritance.Expected.product-dto.ts")] + [InlineData(typeof(ProductDto), "TypeGen.FileContentTest.UseDefaultExportBreaksInterfaceInheritance.Expected.product-dto.ts")] public async Task TestUseDefaultExportBreaksInterfaceInheritanceGenerationSpec(Type type, string expectedLocation) { var generationSpec = new UseDefaultExportBreaksInterfaceInheritanceGenerationSpec(); diff --git a/src/TypeGen/TypeGen.IntegrationTest/tgconfig.json b/src/TypeGen/TypeGen.FileContentTest/tgconfig.json similarity index 100% rename from src/TypeGen/TypeGen.IntegrationTest/tgconfig.json rename to src/TypeGen/TypeGen.FileContentTest/tgconfig.json diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Bar.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Bar.cs deleted file mode 100644 index f1fb285c..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Bar.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.Blacklist.Entities; - -public class Bar -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Baz.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Baz.cs deleted file mode 100644 index f484f56f..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/Baz.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.Blacklist.Entities; - -public class Baz -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/CustomGeneric.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/CustomGeneric.cs deleted file mode 100644 index 7ace6854..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/CustomGeneric.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.Blacklist.Entities; - -public class CustomGeneric -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/IFoo.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/IFoo.cs deleted file mode 100644 index 2897be96..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/IFoo.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.Blacklist.Entities; - -public interface IFoo -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/MyRecord.cs b/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/MyRecord.cs deleted file mode 100644 index be551329..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/Blacklist/Entities/MyRecord.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace TypeGen.IntegrationTest.Blacklist.Entities; - -public record MyRecord(); \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/CommonCasesGenerationTest.cs b/src/TypeGen/TypeGen.IntegrationTest/CommonCases/CommonCasesGenerationTest.cs deleted file mode 100644 index 9bbfff65..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/CommonCasesGenerationTest.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Threading.Tasks; -using TypeGen.IntegrationTest.CommonCases.Entities; -using TypeGen.IntegrationTest.CommonCases.Entities.Constants; -using TypeGen.IntegrationTest.CommonCases.Entities.ErrorCase; -using TypeGen.IntegrationTest.CommonCases.Entities.Structs; -using TypeGen.IntegrationTest.DefaultExport.Entities; -using TypeGen.IntegrationTest.IgnoreBaseInterfaces.Entities; -using TypeGen.IntegrationTest.TestingUtils; -using Xunit; -using Gen = TypeGen.Core.Generator; -using CustomBaseClass = TypeGen.IntegrationTest.CommonCases.Entities.CustomBaseClass; -using CustomBaseCustomImport = TypeGen.IntegrationTest.CommonCases.Entities.CustomBaseCustomImport; -using CustomEmptyBaseClass = TypeGen.IntegrationTest.CommonCases.Entities.CustomEmptyBaseClass; -using DefaultMemberValues = TypeGen.IntegrationTest.CommonCases.Entities.DefaultMemberValues; -using ExtendedPrimitivesClass = TypeGen.IntegrationTest.CommonCases.Entities.ExtendedPrimitivesClass; -using ExternalDepsClass = TypeGen.IntegrationTest.CommonCases.Entities.ExternalDepsClass; -using ITestInterface = TypeGen.IntegrationTest.CommonCases.Entities.ITestInterface; -using LiteDbEntity = TypeGen.IntegrationTest.CommonCases.Entities.LiteDbEntity; -using NoSlashOutputDir = TypeGen.IntegrationTest.CommonCases.Entities.NoSlashOutputDir; -using ReadonlyInterface = TypeGen.IntegrationTest.CommonCases.Entities.ReadonlyInterface; -using StaticReadonly = TypeGen.IntegrationTest.CommonCases.Entities.StaticReadonly; -using StrictNullsClass = TypeGen.IntegrationTest.CommonCases.Entities.StrictNullsClass; -using TestInterface = TypeGen.IntegrationTest.CommonCases.Entities.TestInterface; -using TypeUnions = TypeGen.IntegrationTest.CommonCases.Entities.TypeUnions; - -namespace TypeGen.IntegrationTest.CommonCases -{ - public class CommonCasesGenerationTest : GenerationTestBase - { - /// - /// Tests if types are correctly translated to TypeScript. - /// The tested types contain all major use cases that should be supported. - /// - /// - /// - /// - [Theory] - [InlineData(typeof(FooConstants), "TypeGen.IntegrationTest.CommonCases.Expected.foo-constants.ts")] - [InlineData(typeof(CustomBaseCustomImport), "TypeGen.IntegrationTest.CommonCases.Expected.custom-base-custom-import.ts")] - [InlineData(typeof(Bar), "TypeGen.IntegrationTest.CommonCases.Expected.bar.ts")] - [InlineData(typeof(Entities.BaseClass<>), "TypeGen.IntegrationTest.CommonCases.Expected.base-class.ts")] - [InlineData(typeof(BaseClass2<>), "TypeGen.IntegrationTest.CommonCases.Expected.base-class2.ts")] - [InlineData(typeof(C), "TypeGen.IntegrationTest.CommonCases.Expected.c.ts")] - [InlineData(typeof(CustomBaseClass), "TypeGen.IntegrationTest.CommonCases.Expected.custom-base-class.ts")] - [InlineData(typeof(CustomEmptyBaseClass), "TypeGen.IntegrationTest.CommonCases.Expected.custom-empty-base-class.ts")] - [InlineData(typeof(D), "TypeGen.IntegrationTest.CommonCases.Expected.d.ts")] - [InlineData(typeof(DefaultMemberValues), "TypeGen.IntegrationTest.CommonCases.Expected.default-member-values.ts")] - [InlineData(typeof(EClass), "TypeGen.IntegrationTest.CommonCases.Expected.e-class.ts")] - [InlineData(typeof(ExtendedPrimitivesClass), "TypeGen.IntegrationTest.CommonCases.Expected.extended-primitives-class.ts")] - [InlineData(typeof(ExternalDepsClass), "TypeGen.IntegrationTest.CommonCases.Expected.external-deps-class.ts")] - [InlineData(typeof(FClass), "TypeGen.IntegrationTest.CommonCases.Expected.f-class.ts")] - [InlineData(typeof(FooType), "TypeGen.IntegrationTest.CommonCases.Expected.foo-type.ts")] - [InlineData(typeof(Foo), "TypeGen.IntegrationTest.CommonCases.Expected.foo.ts")] - [InlineData(typeof(Entities.GenericBaseClass<>), "TypeGen.IntegrationTest.CommonCases.Expected.generic-base-class.ts")] - [InlineData(typeof(GenericClass<>), "TypeGen.IntegrationTest.CommonCases.Expected.generic-class.ts")] - [InlineData(typeof(Entities.GenericWithRestrictions<>), "TypeGen.IntegrationTest.CommonCases.Expected.generic-with-restrictions.ts")] - [InlineData(typeof(ITestInterface), "TypeGen.IntegrationTest.CommonCases.Expected.i-test-interface.ts")] - [InlineData(typeof(LiteDbEntity), "TypeGen.IntegrationTest.CommonCases.Expected.lite-db-entity.ts")] - [InlineData(typeof(ReadonlyInterface), "TypeGen.IntegrationTest.CommonCases.Expected.readonly-interface.ts")] - [InlineData(typeof(StandaloneEnum), "TypeGen.IntegrationTest.CommonCases.Expected.standalone-enum.ts")] - [InlineData(typeof(EnumShortValues), "TypeGen.IntegrationTest.CommonCases.Expected.enum-short-values.ts")] - [InlineData(typeof(EnumAsUnionType), "TypeGen.IntegrationTest.CommonCases.Expected.enum-as-union-type.ts")] - [InlineData(typeof(DictionaryWithEnumKey), "TypeGen.IntegrationTest.CommonCases.Expected.dictionary-with-enum-key.ts")] - [InlineData(typeof(DictionaryStringObjectErrorCase), "TypeGen.IntegrationTest.CommonCases.Expected.dictionary-string-object-error-case.ts")] - [InlineData(typeof(StaticReadonly), "TypeGen.IntegrationTest.CommonCases.Expected.static-readonly.ts")] - [InlineData(typeof(StrictNullsClass), "TypeGen.IntegrationTest.CommonCases.Expected.strict-nulls-class.ts")] - [InlineData(typeof(TypeUnions), "TypeGen.IntegrationTest.CommonCases.Expected.type-unions.ts")] - [InlineData(typeof(WithGenericBaseClassCustomType), "TypeGen.IntegrationTest.CommonCases.Expected.with-generic-base-class-custom-type.ts")] - [InlineData(typeof(WithIgnoredBaseAndCustomBase), "TypeGen.IntegrationTest.CommonCases.Expected.with-ignored-base-and-custom-base.ts")] - [InlineData(typeof(WithIgnoredBase), "TypeGen.IntegrationTest.CommonCases.Expected.with-ignored-base.ts")] - [InlineData(typeof(NoSlashOutputDir), "TypeGen.IntegrationTest.CommonCases.Expected.no.slash.output.dir.no-slash-output-dir.ts")] - [InlineData(typeof(Entities.BaseClass<>), "TypeGen.IntegrationTest.CommonCases.Expected.test_classes.base-class.ts")] - [InlineData(typeof(BaseClass2<>), "TypeGen.IntegrationTest.CommonCases.Expected.test_classes.base-class2.ts")] - [InlineData(typeof(CircularRefClass1), "TypeGen.IntegrationTest.CommonCases.Expected.test_classes.circular-ref-class1.ts")] - [InlineData(typeof(CircularRefClass2), "TypeGen.IntegrationTest.CommonCases.Expected.test_classes.circular-ref-class2.ts")] - [InlineData(typeof(TestClass<,>), "TypeGen.IntegrationTest.CommonCases.Expected.test_classes.test-class.ts")] - [InlineData(typeof(TestEnum), "TypeGen.IntegrationTest.CommonCases.Expected.test_enums.test-enum.ts")] - [InlineData(typeof(TestInterface), "TypeGen.IntegrationTest.CommonCases.Expected.test_interfaces.test-interface.ts")] - [InlineData(typeof(NestedEntity), "TypeGen.IntegrationTest.CommonCases.Expected.very.nested.directory.nested-entity.ts")] - [InlineData(typeof(ArrayOfNullable), "TypeGen.IntegrationTest.CommonCases.Expected.array-of-nullable.ts")] - - // now do the cases above for structs (when possible) - - [InlineData(typeof(Entities.Constants.Structs.FooConstants), "TypeGen.IntegrationTest.CommonCases.Expected.foo-constants.ts")] - [InlineData(typeof(Entities.Structs.CustomBaseCustomImport), "TypeGen.IntegrationTest.CommonCases.Expected.custom-base-custom-import.ts")] - [InlineData(typeof(Entities.Structs.CustomBaseClass), "TypeGen.IntegrationTest.CommonCases.Expected.custom-base-class.ts")] - [InlineData(typeof(Entities.Structs.CustomEmptyBaseClass), "TypeGen.IntegrationTest.CommonCases.Expected.custom-empty-base-class.ts")] - [InlineData(typeof(Entities.Structs.DefaultMemberValues), "TypeGen.IntegrationTest.CommonCases.Expected.default-member-values_struct.ts")] - [InlineData(typeof(Entities.Structs.ExtendedPrimitivesClass), "TypeGen.IntegrationTest.CommonCases.Expected.extended-primitives-class.ts")] - [InlineData(typeof(Entities.Structs.ExternalDepsClass), "TypeGen.IntegrationTest.CommonCases.Expected.external-deps-class.ts")] - [InlineData(typeof(Entities.Structs.GenericBaseClass<>), "TypeGen.IntegrationTest.CommonCases.Expected.generic-base-class.ts")] - [InlineData(typeof(Entities.Structs.GenericWithRestrictions<>), "TypeGen.IntegrationTest.CommonCases.Expected.generic-with-restrictions.ts")] - [InlineData(typeof(Entities.Structs.ITestInterface), "TypeGen.IntegrationTest.CommonCases.Expected.i-test-interface.ts")] - [InlineData(typeof(Entities.Structs.LiteDbEntity), "TypeGen.IntegrationTest.CommonCases.Expected.lite-db-entity.ts")] - [InlineData(typeof(Entities.Structs.ReadonlyInterface), "TypeGen.IntegrationTest.CommonCases.Expected.readonly-interface.ts")] - [InlineData(typeof(Entities.Structs.StaticReadonly), "TypeGen.IntegrationTest.CommonCases.Expected.static-readonly.ts")] - [InlineData(typeof(Entities.Structs.StrictNullsClass), "TypeGen.IntegrationTest.CommonCases.Expected.strict-nulls-class.ts")] - [InlineData(typeof(Entities.Structs.TypeUnions), "TypeGen.IntegrationTest.CommonCases.Expected.type-unions.ts")] - [InlineData(typeof(Entities.Structs.NoSlashOutputDir), "TypeGen.IntegrationTest.CommonCases.Expected.no.slash.output.dir.no-slash-output-dir.ts")] - [InlineData(typeof(Entities.Structs.TestInterface), "TypeGen.IntegrationTest.CommonCases.Expected.test_interfaces.test-interface.ts")] - public async Task TestCommonCases(Type type, string expectedLocation) - { - await TestFromAssembly(type, expectedLocation); - } - } -} diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/NotGeneratedBaseClass.cs b/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/NotGeneratedBaseClass.cs deleted file mode 100644 index 8bb32455..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/NotGeneratedBaseClass.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.CommonCases.Entities -{ - public class NotGeneratedBaseClass - { - } -} diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/IBar.cs b/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/IBar.cs deleted file mode 100644 index e8dd97db..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/IBar.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs; - -public interface IBar -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/IFoo.cs b/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/IFoo.cs deleted file mode 100644 index 82342e3b..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/CommonCases/Entities/Structs/IFoo.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.CommonCases.Entities.Structs; - -public interface IFoo -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/Entities/ITest.cs b/src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/Entities/ITest.cs deleted file mode 100644 index 533cf50d..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/CustomBaseInterfaces/Entities/ITest.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.CustomBaseInterfaces.Entities; - -public interface ITest -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Entities/Child.cs b/src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Entities/Child.cs deleted file mode 100644 index b9b24389..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/ExportTypesAsInterfacesByDefault/Entities/Child.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.ExportTypesAsInterfacesByDefault.Entities; - -public class Child -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/Entities/ITest.cs b/src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/Entities/ITest.cs deleted file mode 100644 index df86d689..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/IgnoreBaseInterfaces/Entities/ITest.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.IgnoreBaseInterfaces.Entities; - -public interface ITest -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/ImportType/Entities/DepClass.cs b/src/TypeGen/TypeGen.IntegrationTest/ImportType/Entities/DepClass.cs deleted file mode 100644 index 9fdf5934..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/ImportType/Entities/DepClass.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.ImportType.Entities; - -public class DepClass -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/StructImplementsInterfaces/Entities/ImplementsInterfaces.cs b/src/TypeGen/TypeGen.IntegrationTest/StructImplementsInterfaces/Entities/ImplementsInterfaces.cs deleted file mode 100644 index 5d168466..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/StructImplementsInterfaces/Entities/ImplementsInterfaces.cs +++ /dev/null @@ -1,10 +0,0 @@ -using TypeGen.Core.TypeAnnotations; -using TypeGen.IntegrationTest.CommonCases.Entities.Structs; - -namespace TypeGen.IntegrationTest.StructImplementsInterfaces.Entities; - -[ExportTsClass] -public struct ImplementsInterfaces : IFoo, IBar -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsClass.cs b/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsClass.cs deleted file mode 100644 index b21e9476..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsClass.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace TypeGen.IntegrationTest.TsClassExtendsTsInterface.Entities; - -public class TsClass : TsInterface -{ -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsInterface.cs b/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsInterface.cs deleted file mode 100644 index 6ce09853..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/TsClassExtendsTsInterface/Entities/TsInterface.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.TsClassExtendsTsInterface.Entities; - -public class TsInterface -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Base.cs b/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Base.cs deleted file mode 100644 index 5ca815e1..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Base.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.TsInterfaceInheritance.Entities; - -public class Base -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Sub.cs b/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Sub.cs deleted file mode 100644 index 046a5803..00000000 --- a/src/TypeGen/TypeGen.IntegrationTest/TsInterfaceInheritance/Entities/Sub.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TypeGen.IntegrationTest.TsInterfaceInheritance.Entities; - -public class Sub : Base -{ - -} \ No newline at end of file diff --git a/src/TypeGen/TypeGen.sln b/src/TypeGen/TypeGen.sln index 67bdf1d4..6013efa2 100644 --- a/src/TypeGen/TypeGen.sln +++ b/src/TypeGen/TypeGen.sln @@ -11,7 +11,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TypeGen.Core.Test", "TypeGe EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TypeGen.Cli.Test", "TypeGen.Cli.Test\TypeGen.Cli.Test.csproj", "{7A524558-A065-44EB-B9BC-1DC46ED4042C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TypeGen.IntegrationTest", "TypeGen.IntegrationTest\TypeGen.IntegrationTest.csproj", "{CC91A6B3-AA7E-42B5-B920-5F21DB14D791}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TypeGen.FileContentTest", "TypeGen.FileContentTest\TypeGen.FileContentTest.csproj", "{CC91A6B3-AA7E-42B5-B920-5F21DB14D791}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From 751b12ebdd1cb447c42e9c6094410fb43d0f42e2 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Mon, 4 Sep 2023 17:24:27 +0200 Subject: [PATCH 15/16] fixed OnBeforeGeneration and OnBeforeBarrelGeneration logic --- src/TypeGen/TypeGen.Core/Generator/Generator.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/TypeGen/TypeGen.Core/Generator/Generator.cs b/src/TypeGen/TypeGen.Core/Generator/Generator.cs index f8636184..35b56a69 100644 --- a/src/TypeGen/TypeGen.Core/Generator/Generator.cs +++ b/src/TypeGen/TypeGen.Core/Generator/Generator.cs @@ -145,11 +145,13 @@ public IEnumerable Generate(IEnumerable generationSpecs) // generate types + foreach (GenerationSpec generationSpec in generationSpecs) + generationSpec.OnBeforeGeneration(new OnBeforeGenerationArgs(Options)); + foreach (GenerationSpec generationSpec in generationSpecs) { _metadataReaderFactory.GenerationSpec = generationSpec; - generationSpec.OnBeforeGeneration(new OnBeforeGenerationArgs(Options)); - + foreach (KeyValuePair kvp in generationSpec.TypeSpecs) files.AddRange(GenerateMarkedType(kvp.Key)); } @@ -158,12 +160,12 @@ public IEnumerable Generate(IEnumerable generationSpecs) // generate barrels - if (Options.CreateIndexFile) - files.AddRange(GenerateIndexFile(files)); - foreach (GenerationSpec generationSpec in generationSpecs) generationSpec.OnBeforeBarrelGeneration(new OnBeforeBarrelGenerationArgs(Options, files.ToList())); + if (Options.CreateIndexFile) + files.AddRange(GenerateIndexFile(files)); + foreach (GenerationSpec generationSpec in generationSpecs) foreach (BarrelSpec barrelSpec in generationSpec.BarrelSpecs) files.AddRange(GenerateBarrel(barrelSpec)); From 7f353d519dd460eed05005f7267b2b8c8d36fcd4 Mon Sep 17 00:00:00 2001 From: Jacek Burzynski Date: Mon, 4 Sep 2023 17:27:13 +0200 Subject: [PATCH 16/16] build fix --- .../TypeGen.FileContentTest/TypeGen.FileContentTest.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TypeGen/TypeGen.FileContentTest/TypeGen.FileContentTest.csproj b/src/TypeGen/TypeGen.FileContentTest/TypeGen.FileContentTest.csproj index 6719fe62..93719d7e 100644 --- a/src/TypeGen/TypeGen.FileContentTest/TypeGen.FileContentTest.csproj +++ b/src/TypeGen/TypeGen.FileContentTest/TypeGen.FileContentTest.csproj @@ -13,7 +13,7 @@ - bin\Release\TypeGen.IntegrationTest.xml + bin\Release\TypeGen.FileContentTest.xml