aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-04-28 14:49:49 +0100
committerJon Skeet <jonskeet@google.com>2015-04-28 14:53:24 +0100
commitf3504cf3b1d456a843e8242fdee9ba0bf2991dc1 (patch)
tree019441e4649f66f6273a13bcff5dbafbd12fc9b6 /csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
parentb977c3ed63146525064463c33ddfaa96152989ed (diff)
downloadprotobuf-f3504cf3b1d456a843e8242fdee9ba0bf2991dc1.tar.gz
protobuf-f3504cf3b1d456a843e8242fdee9ba0bf2991dc1.tar.bz2
protobuf-f3504cf3b1d456a843e8242fdee9ba0bf2991dc1.zip
First part of making the C# runtime work with the new codegen.
1) Remove CSharpOptions 2) A new version of DescriptorProtoFile (with manual changes from codegen - it would otherwise be Descriptor.cs) 3) Turn off CLS compliance (which we'll remove from the codebase entirely; I don't think it's actually relevant these days) 4) Add "public imports" to FileDescriptor, with code broadly copied from the Java codebase. Lots more changes to commit before it will build and tests run, but one step at a time...
Diffstat (limited to 'csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs')
-rw-r--r--csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs54
1 files changed, 1 insertions, 53 deletions
diff --git a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
index 6d17ae2a..98de5435 100644
--- a/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
+++ b/csharp/src/ProtocolBuffers/Descriptors/FieldDescriptor.cs
@@ -51,7 +51,6 @@ namespace Google.ProtocolBuffers.Descriptors
private FieldType fieldType;
private MappedType mappedType;
- private CSharpFieldOptions csharpFieldOptions;
private readonly object optionsLock = new object();
internal FieldDescriptor(FieldDescriptorProto proto, FileDescriptor file,
@@ -101,38 +100,6 @@ namespace Google.ProtocolBuffers.Descriptors
file.DescriptorPool.AddSymbol(this);
}
- private CSharpFieldOptions BuildOrFakeCSharpOptions()
- {
- // TODO(jonskeet): Check if we could use FileDescriptorProto.Descriptor.Name - interesting bootstrap issues
- if (File.Proto.Name == "google/protobuf/csharp_options.proto")
- {
- if (Name == "csharp_field_options")
- {
- return new CSharpFieldOptions.Builder {PropertyName = "CSharpFieldOptions"}.Build();
- }
- if (Name == "csharp_file_options")
- {
- return new CSharpFieldOptions.Builder {PropertyName = "CSharpFileOptions"}.Build();
- }
- }
- CSharpFieldOptions.Builder builder = CSharpFieldOptions.CreateBuilder();
- if (Proto.Options.HasExtension(DescriptorProtos.CSharpOptions.CSharpFieldOptions))
- {
- builder.MergeFrom(Proto.Options.GetExtension(DescriptorProtos.CSharpOptions.CSharpFieldOptions));
- }
- if (!builder.HasPropertyName)
- {
- string fieldName = FieldType == FieldType.Group ? MessageType.Name : Name;
- string propertyName = NameHelpers.UnderscoresToPascalCase(fieldName);
- if (propertyName == ContainingType.Name)
- {
- propertyName += "_";
- }
- builder.PropertyName = propertyName;
- }
- return builder.Build();
- }
-
/// <summary>
/// Maps a field type as included in the .proto file to a FieldType.
/// </summary>
@@ -286,26 +253,7 @@ namespace Google.ProtocolBuffers.Descriptors
{
get { return containingType; }
}
-
- /// <summary>
- /// Returns the C#-specific options for this field descriptor. This will always be
- /// completely filled in.
- /// </summary>
- public CSharpFieldOptions CSharpOptions
- {
- get
- {
- lock (optionsLock)
- {
- if (csharpFieldOptions == null)
- {
- csharpFieldOptions = BuildOrFakeCSharpOptions();
- }
- }
- return csharpFieldOptions;
- }
- }
-
+
/// <summary>
/// For extensions defined nested within message types, gets
/// the outer type. Not valid for non-extension fields.