aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp
diff options
context:
space:
mode:
authorGravatar Jon Skeet <skeet@pobox.com>2008-10-02 21:46:17 +0100
committerGravatar Jon Skeet <skeet@pobox.com>2008-10-02 21:46:17 +0100
commit7f90d8ee57d4af4215bc31dbb07726c023c5e047 (patch)
tree9a892e6f6f68e4a75c5e766d95e4cd42857b1bc6 /csharp
parent7fd62ffd77ccedfc6dbe2384901b375859b726b6 (diff)
Made things a bit more public for the sake of ProtoGen
Diffstat (limited to 'csharp')
-rw-r--r--csharp/ProtocolBuffers/Descriptors/FileDescriptor.cs7
-rw-r--r--csharp/ProtocolBuffers/Properties/AssemblyInfo.cs6
-rw-r--r--csharp/ProtocolBuffers/TextFormat.cs1
-rw-r--r--csharp/ProtocolBuffers/TextGenerator.cs26
4 files changed, 33 insertions, 7 deletions
diff --git a/csharp/ProtocolBuffers/Descriptors/FileDescriptor.cs b/csharp/ProtocolBuffers/Descriptors/FileDescriptor.cs
index 429282b7..3fa3360e 100644
--- a/csharp/ProtocolBuffers/Descriptors/FileDescriptor.cs
+++ b/csharp/ProtocolBuffers/Descriptors/FileDescriptor.cs
@@ -175,7 +175,8 @@ namespace Google.ProtocolBuffers.Descriptors {
/// </summary>
/// <param name="proto">The protocol message form of the FileDescriptor.</param>
/// <param name="dependencies">FileDescriptors corresponding to all of the
- /// file's dependencies, in the exact order listed in the .proto file</param>
+ /// file's dependencies, in the exact order listed in the .proto file. May be null,
+ /// in which case it is treated as an empty array.</param>
/// <exception cref="DescriptorValidationException">If <paramref name="proto"/> is not
/// a valid descriptor. This can occur for a number of reasons, such as a field
/// having an undefined type or because two messages were defined with the same name.</exception>
@@ -189,6 +190,10 @@ namespace Google.ProtocolBuffers.Descriptors {
// FieldDescriptor for an embedded message contains a pointer directly
// to the Descriptor for that message's type. We also detect undefined
// types in the linking step.
+ if (dependencies == null) {
+ dependencies = new FileDescriptor[0];
+ }
+
DescriptorPool pool = new DescriptorPool(dependencies);
FileDescriptor result = new FileDescriptor(proto, dependencies, pool);
diff --git a/csharp/ProtocolBuffers/Properties/AssemblyInfo.cs b/csharp/ProtocolBuffers/Properties/AssemblyInfo.cs
index 8949ec95..749a2e45 100644
--- a/csharp/ProtocolBuffers/Properties/AssemblyInfo.cs
+++ b/csharp/ProtocolBuffers/Properties/AssemblyInfo.cs
@@ -55,3 +55,9 @@ using System.Runtime.CompilerServices;
"72f738140072bb69990bc4f98a21365de2c105e848974a3d210e938b0a56103c0662901efd6b78"+
"0ee6dbe977923d46a8fda18fb25c65dd73b149a5cd9f3100668b56649932dadd8cf5be52eb1dce"+
"ad5cedbf")]
+[assembly: InternalsVisibleTo("ProtoGen,PublicKey=" +
+"00240000048000009400000006020000002400005253413100040000010001006d739020e13bdc" +
+"038e86fa8aa5e1b13aae65d3ae79d622816c6067ab5b6955be50cc887130117582349208c13a55" +
+"5e09a6084558f989ccde66094f07822808d3a9b922b0e85b912070032e90bb35360be7efb7982b" +
+"702d7a5c6ed1e21d8ca587b4f4c9d2b81210d3641cc75f506cdfc628ac5453ff0a6886986c981d" +
+"12245bc7")]
diff --git a/csharp/ProtocolBuffers/TextFormat.cs b/csharp/ProtocolBuffers/TextFormat.cs
index 48b2d8af..d487bd61 100644
--- a/csharp/ProtocolBuffers/TextFormat.cs
+++ b/csharp/ProtocolBuffers/TextFormat.cs
@@ -314,6 +314,7 @@ namespace Google.ProtocolBuffers {
internal static string EscapeText(string input) {
return EscapeBytes(ByteString.CopyFromUtf8(input));
}
+
/// <summary>
/// Escapes bytes in the format used in protocol buffer text format, which
/// is the same as the format used for C string literals. All bytes
diff --git a/csharp/ProtocolBuffers/TextGenerator.cs b/csharp/ProtocolBuffers/TextGenerator.cs
index 24961570..3cb8b490 100644
--- a/csharp/ProtocolBuffers/TextGenerator.cs
+++ b/csharp/ProtocolBuffers/TextGenerator.cs
@@ -20,9 +20,9 @@ using System.Text;
namespace Google.ProtocolBuffers {
/// <summary>
- /// Helper class to control indentation
+ /// Helper class to control indentation. Used for TextFormat and by ProtoGen.
/// </summary>
- internal sealed class TextGenerator {
+ public sealed class TextGenerator {
/// <summary>
/// Writer to write formatted text to.
@@ -40,9 +40,10 @@ namespace Google.ProtocolBuffers {
readonly StringBuilder indent = new StringBuilder();
/// <summary>
- /// Creates a generator writing to the given writer.
+ /// Creates a generator writing to the given writer. The writer
+ /// is not closed by this class.
/// </summary>
- internal TextGenerator(TextWriter writer) {
+ public TextGenerator(TextWriter writer) {
this.writer = writer;
}
@@ -51,20 +52,33 @@ namespace Google.ProtocolBuffers {
/// will be inserted at the beginning of each line of text. Indent() may
/// be called multiple times to produce deeper indents.
/// </summary>
- internal void Indent() {
+ public void Indent() {
indent.Append(" ");
}
/// <summary>
/// Reduces the current indent level by two spaces.
/// </summary>
- internal void Outdent() {
+ public void Outdent() {
if (indent.Length == 0) {
throw new InvalidOperationException("Too many calls to Outdent()");
}
indent.Length -= 2;
}
+ public void WriteLine(string text) {
+ Print(text);
+ Print("\n");
+ }
+
+ public void WriteLine(string format, params object[] args) {
+ WriteLine(string.Format(format, args));
+ }
+
+ public void WriteLine() {
+ WriteLine("");
+ }
+
/// <summary>
/// Prints the given text to the output stream, indenting at line boundaries.
/// </summary>