Skip to content

Commit

Permalink
Set extension bounds to 100 and 10000 where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
Katy Coe committed May 2, 2016
1 parent 9bdae43 commit 5f6b2f1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion protobuf.cs
Expand Up @@ -174,7 +174,9 @@ public class MessageNode : ILanguageNode, IImportUser {
if (line.Trim().Length != 0)
result += "\t" + line + "\n";
if (AcceptsExtensions)
result += "\textensions " + ExtendLowerBound + " to " + ExtendUpperBound + ";\n";
result += "\textensions "
+ (FieldUpperBound < 100? 100 : ExtendLowerBound) + " to "
+ (FieldUpperBound > ExtendUpperBound? ExtendUpperBound : 10000) + ";\n";

return result + "}\n";
}
Expand Down Expand Up @@ -221,6 +223,12 @@ public class MessageNode : ILanguageNode, IImportUser {
public int ExtendLowerBound;
public int ExtendUpperBound;

public int FieldUpperBound {
get {
return Fields.Max(x => x.Tag);
}
}

public MessageNode(TypeName name) {
Name = name;
Enums = new List<EnumNode>();
Expand Down

0 comments on commit 5f6b2f1

Please sign in to comment.