Fixup enum capitalization for protobuf-net

This commit is contained in:
Eric Harding committed 2017-08-18 17:44:55 -04:00
1 parent 56aa30d82a
commit a9ebf9532a
3 files changed
+43 -4

No files matched your search

+3 -2
View File
@@ -4,5 +4,6 @@ git checkout a978575b9e8bc281f7341237cace35220ef0ff35
git apply --ignore-space-change --ignore-whitespace ..\internal_only.patch
cd src\protogen
dotnet build -c release
copy bin\release\net40\*.exe ..\..\windows\bin\
copy bin\release\net40\*.dll ..\..\windows\bin\
copy /y bin\release\net40\*.exe ..\..\..\..\..\windows\bin\
copy /y bin\release\net40\*.dll ..\..\..\..\..\windows\bin\
:: git diff > > internal_only.patch
+40 -2
View File
@@ -1,8 +1,24 @@
diff --git a/src/protobuf-net.Reflection/CSharpCodeGenerator.cs b/src/protobuf-net.Reflection/CSharpCodeGenerator.cs
index edd6f1c..24b117e 100644
index edd6f1c..8be0237 100644
--- a/src/protobuf-net.Reflection/CSharpCodeGenerator.cs
+++ b/src/protobuf-net.Reflection/CSharpCodeGenerator.cs
@@ -204,7 +204,7 @@ namespace ProtoBuf.Reflection
@@ -175,14 +175,7 @@ namespace ProtoBuf.Reflection
/// </summary>
protected override void WriteEnumValue(GeneratorContext ctx, EnumValueDescriptorProto obj, ref object state)
{
- var name = ctx.NameNormalizer.GetName(obj);
- if (name != obj.Name)
- {
- var tw = ctx.Write($@"[global::ProtoBuf.ProtoEnum(");
- tw.Write($@"Name = @""{obj.Name}""");
- tw.WriteLine(")]");
- }
-
+ var name = obj.Name;
WriteOptions(ctx, obj.Options);
ctx.WriteLine($"{Escape(name)} = {obj.Number},");
}
@@ -204,7 +197,7 @@ namespace ProtoBuf.Reflection
if (name != obj.Name) tw.Write($@"Name = @""{obj.Name}""");
tw.WriteLine(")]");
WriteOptions(ctx, obj.Options);
@@ -11,3 +27,25 @@ index edd6f1c..24b117e 100644
if (obj.ExtensionRanges.Count != 0) tw.Write(" : global::ProtoBuf.IExtensible");
tw.WriteLine();
ctx.WriteLine("{").Indent();
@@ -332,7 +325,7 @@ namespace ProtoBuf.Reflection
if (found != null)
{
- defaultValue = ctx.NameNormalizer.GetName(found);
+ defaultValue = found.Name;
}
if (!string.IsNullOrWhiteSpace(defaultValue))
{
diff --git a/src/protobuf-net.Reflection/CodeGenerator.cs b/src/protobuf-net.Reflection/CodeGenerator.cs
index 2d3ede7..9d88d2f 100644
--- a/src/protobuf-net.Reflection/CodeGenerator.cs
+++ b/src/protobuf-net.Reflection/CodeGenerator.cs
@@ -134,7 +134,7 @@ namespace ProtoBuf.Reflection
string generated;
using (var buffer = new StringWriter())
{
- var ctx = new GeneratorContext(file, normalizer ?? NameNormalizer.Default, buffer, Indent);
+ var ctx = new GeneratorContext(file, normalizer ?? NameNormalizer.Null, buffer, Indent);
ctx.BuildTypeIndex(); // populates for TryFind<T>
WriteFile(ctx, file);
Binary file not shown.