diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index b969e6600..21e74d1b9 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -1390,7 +1390,9 @@ namespace PascalABCCompiler.NETGenerator { FieldBuilder fb = cur_type.DefineField(name, helper.GetTypeReference(type).tp, FieldAttributes.Static | FieldAttributes.Public | FieldAttributes.Literal); Type t = helper.GetTypeReference(type).tp; - if (!t.Name.StartsWith("NewSet") && t.IsEnum) // SSM 05.11.24 + + // Для инстанцированных generic типов вызов .IsEnum приводит к исключению + if (!t.IsConstructedGenericType() && t.IsEnum) { if (!(t is EnumBuilder)) fb.SetConstant(Enum.ToObject(t, (constant_value as IEnumConstNode).constant_value)); diff --git a/NETGenerator/TypeExt.cs b/NETGenerator/TypeExt.cs new file mode 100644 index 000000000..7eb583fd4 --- /dev/null +++ b/NETGenerator/TypeExt.cs @@ -0,0 +1,15 @@ +using System; + +namespace PascalABCCompiler.NETGenerator +{ + internal static class TypeExt + { + /// + /// Повторяет работу свойства System.Type.IsConstructedGenericType из net fx 4.5 + /// + public static bool IsConstructedGenericType(this Type t) + { + return t.IsGenericType && !t.IsGenericTypeDefinition; + } + } +}