Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
52fee0e8
Unverified
Commit
52fee0e8
authored
Dec 11, 2018
by
Hao Nguyen
Committed by
GitHub
Dec 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5445 from haon4/master
Make Protobuf compatible with C# 6
parents
1d900798
db0a9e0b
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
12 deletions
+26
-12
FieldMaskTree.cs
csharp/src/Google.Protobuf/FieldMaskTree.cs
+2
-1
Google.Protobuf.csproj
csharp/src/Google.Protobuf/Google.Protobuf.csproj
+1
-0
FileDescriptor.cs
csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
+10
-7
SingleFieldAccessor.cs
csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
+12
-3
TimestampPartial.cs
...rp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs
+1
-1
No files found.
csharp/src/Google.Protobuf/FieldMaskTree.cs
View file @
52fee0e8
...
...
@@ -120,7 +120,8 @@ namespace Google.Protobuf
return
this
;
}
if
(!
node
.
Children
.
TryGetValue
(
part
,
out
var
childNode
))
Node
childNode
;
if
(!
node
.
Children
.
TryGetValue
(
part
,
out
childNode
))
{
createNewBranch
=
true
;
childNode
=
new
Node
();
...
...
csharp/src/Google.Protobuf/Google.Protobuf.csproj
View file @
52fee0e8
...
...
@@ -5,6 +5,7 @@
<Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.6.1</VersionPrefix>
<LangVersion>6</LangVersion>
<Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.0;net45</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
...
...
csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs
View file @
52fee0e8
...
...
@@ -98,8 +98,9 @@ namespace Google.Protobuf.Reflection
}
}
return
dictionary
;
}
IDescriptor
FindDescriptorForPath
(
IList
<
int
>
path
)
private
IDescriptor
FindDescriptorForPath
(
IList
<
int
>
path
)
{
// All complete declarations have an even, non-empty path length
// (There can be an empty path for a descriptor declaration, but that can't have any comments,
...
...
@@ -119,7 +120,7 @@ namespace Google.Protobuf.Reflection
return
current
;
}
DescriptorBase
GetDescriptorFromList
(
IReadOnlyList
<
DescriptorBase
>
list
,
int
index
)
private
DescriptorBase
GetDescriptorFromList
(
IReadOnlyList
<
DescriptorBase
>
list
,
int
index
)
{
// This is fine: it may be a newer version of protobuf than we understand, with a new descriptor
// field.
...
...
@@ -137,7 +138,7 @@ namespace Google.Protobuf.Reflection
return
list
[
index
];
}
IReadOnlyList
<
DescriptorBase
>
GetNestedDescriptorListForField
(
int
fieldNumber
)
private
IReadOnlyList
<
DescriptorBase
>
GetNestedDescriptorListForField
(
int
fieldNumber
)
{
switch
(
fieldNumber
)
{
...
...
@@ -151,11 +152,11 @@ namespace Google.Protobuf.Reflection
return
null
;
}
}
}
internal
DescriptorDeclaration
GetDeclaration
(
IDescriptor
descriptor
)
{
declarations
.
Value
.
TryGetValue
(
descriptor
,
out
var
declaration
);
DescriptorDeclaration
declaration
;
declarations
.
Value
.
TryGetValue
(
descriptor
,
out
declaration
);
return
declaration
;
}
...
...
@@ -191,7 +192,8 @@ namespace Google.Protobuf.Reflection
throw
new
DescriptorValidationException
(
@this
,
"Invalid public dependency index."
);
}
string
name
=
proto
.
Dependency
[
index
];
if
(!
nameToFileMap
.
TryGetValue
(
name
,
out
var
file
))
FileDescriptor
file
;
if
(!
nameToFileMap
.
TryGetValue
(
name
,
out
file
))
{
if
(!
allowUnknownDependencies
)
{
...
...
@@ -414,7 +416,8 @@ namespace Google.Protobuf.Reflection
var
dependencies
=
new
List
<
FileDescriptor
>();
foreach
(
var
dependencyName
in
proto
.
Dependency
)
{
if
(!
descriptorsByName
.
TryGetValue
(
dependencyName
,
out
var
dependency
))
FileDescriptor
dependency
;
if
(!
descriptorsByName
.
TryGetValue
(
dependencyName
,
out
dependency
))
{
throw
new
ArgumentException
(
$"Dependency missing:
{
dependencyName
}
"
);
}
...
...
csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs
View file @
52fee0e8
...
...
@@ -60,13 +60,22 @@ namespace Google.Protobuf.Reflection
if
(
descriptor
.
File
.
Proto
.
Syntax
==
"proto2"
)
{
MethodInfo
hasMethod
=
property
.
DeclaringType
.
GetRuntimeProperty
(
"Has"
+
property
.
Name
).
GetMethod
;
hasDelegate
=
ReflectionUtil
.
CreateFuncIMessageBool
(
hasMethod
??
throw
new
ArgumentException
(
"Not all required properties/methods are available"
));
if
(
hasMethod
==
null
)
{
throw
new
ArgumentException
(
"Not all required properties/methods are available"
);
}
hasDelegate
=
ReflectionUtil
.
CreateFuncIMessageBool
(
hasMethod
);
MethodInfo
clearMethod
=
property
.
DeclaringType
.
GetRuntimeMethod
(
"Clear"
+
property
.
Name
,
ReflectionUtil
.
EmptyTypes
);
clearDelegate
=
ReflectionUtil
.
CreateActionIMessage
(
clearMethod
??
throw
new
ArgumentException
(
"Not all required properties/methods are available"
));
if
(
clearMethod
==
null
)
{
throw
new
ArgumentException
(
"Not all required properties/methods are available"
);
}
clearDelegate
=
ReflectionUtil
.
CreateActionIMessage
(
clearMethod
);
}
else
{
hasDelegate
=
(
_
)
=>
throw
new
InvalidOperationException
(
"HasValue is not implemented for proto3 fields"
);
var
clrType
=
property
.
PropertyType
;
hasDelegate
=
message
=>
{
throw
new
InvalidOperationException
(
"HasValue is not implemented for proto3 fields"
);
};
var
clrType
=
property
.
PropertyType
;
// TODO: Validate that this is a reasonable single field? (Should be a value type, a message type, or string/ByteString.)
object
defaultValue
=
...
...
csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs
View file @
52fee0e8
...
...
@@ -308,7 +308,7 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns>true if the two timestamps refer to the same nanosecond</returns>
public
static
bool
operator
==(
Timestamp
a
,
Timestamp
b
)
{
return
ReferenceEquals
(
a
,
b
)
||
(
a
is
null
?
(
b
is
null
?
true
:
false
)
:
a
.
Equals
(
b
));
return
ReferenceEquals
(
a
,
b
)
||
(
ReferenceEquals
(
a
,
null
)
?
(
ReferenceEquals
(
b
,
null
)
?
true
:
false
)
:
a
.
Equals
(
b
));
}
/// <summary>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment