removing hard code (#3304)
This commit is contained in:
parent
0972d09837
commit
d4173b0bec
|
|
@ -1390,7 +1390,9 @@ namespace PascalABCCompiler.NETGenerator
|
||||||
{
|
{
|
||||||
FieldBuilder fb = cur_type.DefineField(name, helper.GetTypeReference(type).tp, FieldAttributes.Static | FieldAttributes.Public | FieldAttributes.Literal);
|
FieldBuilder fb = cur_type.DefineField(name, helper.GetTypeReference(type).tp, FieldAttributes.Static | FieldAttributes.Public | FieldAttributes.Literal);
|
||||||
Type t = helper.GetTypeReference(type).tp;
|
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))
|
if (!(t is EnumBuilder))
|
||||||
fb.SetConstant(Enum.ToObject(t, (constant_value as IEnumConstNode).constant_value));
|
fb.SetConstant(Enum.ToObject(t, (constant_value as IEnumConstNode).constant_value));
|
||||||
|
|
|
||||||
15
NETGenerator/TypeExt.cs
Normal file
15
NETGenerator/TypeExt.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace PascalABCCompiler.NETGenerator
|
||||||
|
{
|
||||||
|
internal static class TypeExt
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Повторяет работу свойства System.Type.IsConstructedGenericType из net fx 4.5
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsConstructedGenericType(this Type t)
|
||||||
|
{
|
||||||
|
return t.IsGenericType && !t.IsGenericTypeDefinition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue