From e4f1b3a32193089c6278d5fc7415db2ab9d97b8f Mon Sep 17 00:00:00 2001 From: Anton Pavlov Date: Wed, 8 Dec 2021 11:00:10 +0400 Subject: [PATCH 1/3] =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B1=D0=B0=D0=B3=20=D1=81=D0=B5=D1=80=D0=B8=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D0=B8=20=D1=81=20=D0=B8=D0=B3=D0=BD?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BD=D0=B5=D1=81=D0=BA=D0=BE=D0=BB=D1=8C=D0=BA=D0=B8=D1=85=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=B5=D0=B9=20enum?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reinforced.Typings.Tests.csproj | 1 + ...s.EnumStringInitializerIgnoreManyValues.cs | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumStringInitializerIgnoreManyValues.cs diff --git a/Reinforced.Typings.Tests/Reinforced.Typings.Tests.csproj b/Reinforced.Typings.Tests/Reinforced.Typings.Tests.csproj index 0515fb0..ead1255 100644 --- a/Reinforced.Typings.Tests/Reinforced.Typings.Tests.csproj +++ b/Reinforced.Typings.Tests/Reinforced.Typings.Tests.csproj @@ -71,6 +71,7 @@ + diff --git a/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumStringInitializerIgnoreManyValues.cs b/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumStringInitializerIgnoreManyValues.cs new file mode 100644 index 0000000..5a07985 --- /dev/null +++ b/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumStringInitializerIgnoreManyValues.cs @@ -0,0 +1,34 @@ +using Reinforced.Typings.Fluent; +using Xunit; + +namespace Reinforced.Typings.Tests.SpecificCases +{ + public partial class SpecificTestCases + { + enum EnumToIgnoreSomeValues + { + Value1, + Value2, + Value3 + } + + [Fact] + public void EnumMultipleIgnoreValues() + { + const string result = @" +module Reinforced.Typings.Tests.SpecificCases { + export enum SomeInitializerEnum { + Value3 = ""Value3"" + } +}"; + AssertConfiguration(s => + { + s.Global(a => a.DontWriteWarningComment()); + s.ExportAsEnum() + .Value(EnumToIgnoreSomeValues.Value1, d => d.Ignore()) + .Value(EnumToIgnoreSomeValues.Value2, d => d.Ignore()) + .UseString(); + }, result); + } + } +} \ No newline at end of file From 4218d6151dcc23107f9d92bc5be012ebef686179 Mon Sep 17 00:00:00 2001 From: Anton Pavlov Date: Wed, 8 Dec 2021 11:00:10 +0400 Subject: [PATCH 2/3] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=82=D0=B5=D1=81=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...s.EnumStringInitializerIgnoreManyValues.cs | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumStringInitializerIgnoreManyValues.cs b/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumStringInitializerIgnoreManyValues.cs index 5a07985..61e494c 100644 --- a/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumStringInitializerIgnoreManyValues.cs +++ b/Reinforced.Typings.Tests/SpecificCases/SpecificTestCases.EnumStringInitializerIgnoreManyValues.cs @@ -3,32 +3,32 @@ namespace Reinforced.Typings.Tests.SpecificCases { - public partial class SpecificTestCases - { - enum EnumToIgnoreSomeValues - { - Value1, - Value2, - Value3 - } + public partial class SpecificTestCases + { + enum EnumToIgnoreSomeValues + { + Value1, + Value2, + Value3 + } - [Fact] - public void EnumMultipleIgnoreValues() - { - const string result = @" + [Fact] + public void EnumMultipleIgnoreValuesShouldPass() + { + const string result = @" module Reinforced.Typings.Tests.SpecificCases { - export enum SomeInitializerEnum { + export enum EnumToIgnoreSomeValues { Value3 = ""Value3"" } }"; - AssertConfiguration(s => - { - s.Global(a => a.DontWriteWarningComment()); - s.ExportAsEnum() - .Value(EnumToIgnoreSomeValues.Value1, d => d.Ignore()) - .Value(EnumToIgnoreSomeValues.Value2, d => d.Ignore()) - .UseString(); - }, result); - } - } + AssertConfiguration(s => + { + s.Global(a => a.DontWriteWarningComment()); + s.ExportAsEnum() + .Value(EnumToIgnoreSomeValues.Value1, d => d.Ignore()) + .Value(EnumToIgnoreSomeValues.Value2, d => d.Ignore()) + .UseString(); + }, result); + } + } } \ No newline at end of file From cc567d38c9e3e28bdd5a04547100b1ed9c28a997 Mon Sep 17 00:00:00 2001 From: Anton Pavlov Date: Wed, 8 Dec 2021 16:36:15 +0400 Subject: [PATCH 3/3] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D0=B1=D0=B0?= =?UTF-8?q?=D0=B3=D0=B0=20=D1=81=20=D0=BF=D1=80=D0=BE=D0=BF=D1=83=D1=81?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=20=D1=83=D1=87=D0=B5=D1=82=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8F=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B0?= =?UTF-8?q?=20IsIgnored=20=D0=B4=D0=BB=D1=8F=20=D0=B5=D0=BD=D1=83=D0=BC?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reinforced.Typings/Generators/EnumGenerator.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Reinforced.Typings/Generators/EnumGenerator.cs b/Reinforced.Typings/Generators/EnumGenerator.cs index f3751b0..2763545 100644 --- a/Reinforced.Typings/Generators/EnumGenerator.cs +++ b/Reinforced.Typings/Generators/EnumGenerator.cs @@ -55,6 +55,9 @@ public override RtEnum GenerateNode(Type element, RtEnum result, TypeResolver re { var fieldItself = fields[n]; + if (Context.CurrentBlueprint.Ignored.Contains(fieldItself)) + continue; + var attr = Context.CurrentBlueprint.ForEnumValue(fieldItself); if (attr != null) n = attr.Name; if (string.IsNullOrEmpty(n)) n = fieldItself.Name;