@ -42,6 +42,25 @@ using static Google.Protobuf.Reflection.SourceCodeInfo.Types;
namespace Google.Protobuf.Reflection
{
/// <summary>
/// The syntax of a .proto file
/// </summary>
public enum Syntax
{
/// <summary>
/// Proto2 syntax
/// </summary>
Proto2 ,
/// <summary>
/// Proto3 syntax
/// </summary>
Proto3 ,
/// <summary>
/// An unknown declared syntax
/// </summary>
Unknown
}
/// <summary>
/// Describes a .proto file, including everything defined within.
/// IDescriptor is implemented such that the File property returns this descriptor,
@ -87,6 +106,19 @@ namespace Google.Protobuf.Reflection
Extensions = new ExtensionCollection ( this , generatedCodeInfo ? . Extensions ) ;
declarations = new Lazy < Dictionary < IDescriptor , DescriptorDeclaration > > ( CreateDeclarationMap , LazyThreadSafetyMode . ExecutionAndPublication ) ;
if ( ! proto . HasSyntax | | proto . Syntax = = "proto2" )
{
Syntax = Syntax . Proto2 ;
}
else if ( proto . Syntax = = "proto3" )
{
Syntax = Syntax . Proto3 ;
}
else
{
Syntax = Syntax . Unknown ;
}
}
private Dictionary < IDescriptor , DescriptorDeclaration > CreateDeclarationMap ( )
@ -217,6 +249,11 @@ namespace Google.Protobuf.Reflection
/// </value>
internal FileDescriptorProto Proto { get ; }
/// <summary>
/// The syntax of the file
/// </summary>
public Syntax Syntax { get ; }
/// <value>
/// The file name.
/// </value>