Commit 7f90d8ee authored by Jon Skeet's avatar Jon Skeet

Made things a bit more public for the sake of ProtoGen

parent 7fd62ffd
...@@ -175,7 +175,8 @@ namespace Google.ProtocolBuffers.Descriptors { ...@@ -175,7 +175,8 @@ namespace Google.ProtocolBuffers.Descriptors {
/// </summary> /// </summary>
/// <param name="proto">The protocol message form of the FileDescriptor.</param> /// <param name="proto">The protocol message form of the FileDescriptor.</param>
/// <param name="dependencies">FileDescriptors corresponding to all of the /// <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 /// <exception cref="DescriptorValidationException">If <paramref name="proto"/> is not
/// a valid descriptor. This can occur for a number of reasons, such as a field /// 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> /// having an undefined type or because two messages were defined with the same name.</exception>
...@@ -189,6 +190,10 @@ namespace Google.ProtocolBuffers.Descriptors { ...@@ -189,6 +190,10 @@ namespace Google.ProtocolBuffers.Descriptors {
// FieldDescriptor for an embedded message contains a pointer directly // FieldDescriptor for an embedded message contains a pointer directly
// to the Descriptor for that message's type. We also detect undefined // to the Descriptor for that message's type. We also detect undefined
// types in the linking step. // types in the linking step.
if (dependencies == null) {
dependencies = new FileDescriptor[0];
}
DescriptorPool pool = new DescriptorPool(dependencies); DescriptorPool pool = new DescriptorPool(dependencies);
FileDescriptor result = new FileDescriptor(proto, dependencies, pool); FileDescriptor result = new FileDescriptor(proto, dependencies, pool);
......
...@@ -55,3 +55,9 @@ using System.Runtime.CompilerServices; ...@@ -55,3 +55,9 @@ using System.Runtime.CompilerServices;
"72f738140072bb69990bc4f98a21365de2c105e848974a3d210e938b0a56103c0662901efd6b78"+ "72f738140072bb69990bc4f98a21365de2c105e848974a3d210e938b0a56103c0662901efd6b78"+
"0ee6dbe977923d46a8fda18fb25c65dd73b149a5cd9f3100668b56649932dadd8cf5be52eb1dce"+ "0ee6dbe977923d46a8fda18fb25c65dd73b149a5cd9f3100668b56649932dadd8cf5be52eb1dce"+
"ad5cedbf")] "ad5cedbf")]
[assembly: InternalsVisibleTo("ProtoGen,PublicKey=" +
"00240000048000009400000006020000002400005253413100040000010001006d739020e13bdc" +
"038e86fa8aa5e1b13aae65d3ae79d622816c6067ab5b6955be50cc887130117582349208c13a55" +
"5e09a6084558f989ccde66094f07822808d3a9b922b0e85b912070032e90bb35360be7efb7982b" +
"702d7a5c6ed1e21d8ca587b4f4c9d2b81210d3641cc75f506cdfc628ac5453ff0a6886986c981d" +
"12245bc7")]
...@@ -314,6 +314,7 @@ namespace Google.ProtocolBuffers { ...@@ -314,6 +314,7 @@ namespace Google.ProtocolBuffers {
internal static string EscapeText(string input) { internal static string EscapeText(string input) {
return EscapeBytes(ByteString.CopyFromUtf8(input)); return EscapeBytes(ByteString.CopyFromUtf8(input));
} }
/// <summary> /// <summary>
/// Escapes bytes in the format used in protocol buffer text format, which /// 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 /// is the same as the format used for C string literals. All bytes
......
...@@ -20,9 +20,9 @@ using System.Text; ...@@ -20,9 +20,9 @@ using System.Text;
namespace Google.ProtocolBuffers { namespace Google.ProtocolBuffers {
/// <summary> /// <summary>
/// Helper class to control indentation /// Helper class to control indentation. Used for TextFormat and by ProtoGen.
/// </summary> /// </summary>
internal sealed class TextGenerator { public sealed class TextGenerator {
/// <summary> /// <summary>
/// Writer to write formatted text to. /// Writer to write formatted text to.
...@@ -40,9 +40,10 @@ namespace Google.ProtocolBuffers { ...@@ -40,9 +40,10 @@ namespace Google.ProtocolBuffers {
readonly StringBuilder indent = new StringBuilder(); readonly StringBuilder indent = new StringBuilder();
/// <summary> /// <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> /// </summary>
internal TextGenerator(TextWriter writer) { public TextGenerator(TextWriter writer) {
this.writer = writer; this.writer = writer;
} }
...@@ -51,20 +52,33 @@ namespace Google.ProtocolBuffers { ...@@ -51,20 +52,33 @@ namespace Google.ProtocolBuffers {
/// will be inserted at the beginning of each line of text. Indent() may /// will be inserted at the beginning of each line of text. Indent() may
/// be called multiple times to produce deeper indents. /// be called multiple times to produce deeper indents.
/// </summary> /// </summary>
internal void Indent() { public void Indent() {
indent.Append(" "); indent.Append(" ");
} }
/// <summary> /// <summary>
/// Reduces the current indent level by two spaces. /// Reduces the current indent level by two spaces.
/// </summary> /// </summary>
internal void Outdent() { public void Outdent() {
if (indent.Length == 0) { if (indent.Length == 0) {
throw new InvalidOperationException("Too many calls to Outdent()"); throw new InvalidOperationException("Too many calls to Outdent()");
} }
indent.Length -= 2; 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> /// <summary>
/// Prints the given text to the output stream, indenting at line boundaries. /// Prints the given text to the output stream, indenting at line boundaries.
/// </summary> /// </summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment