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
20b7fab0
Unverified
Commit
20b7fab0
authored
Dec 05, 2019
by
Jan Tattermusch
Committed by
GitHub
Dec 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6674 from ObsidianMinor/csharp/general-cleanup
Cleanup various bits of Google.Protobuf
parents
c8a56342
d5e964c8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
19 deletions
+20
-19
GeneratedMessageTest.Proto2.cs
...p/src/Google.Protobuf.Test/GeneratedMessageTest.Proto2.cs
+12
-0
CodedOutputStream.cs
csharp/src/Google.Protobuf/CodedOutputStream.cs
+1
-1
JsonFormatter.cs
csharp/src/Google.Protobuf/JsonFormatter.cs
+1
-1
JsonParser.cs
csharp/src/Google.Protobuf/JsonParser.cs
+1
-1
MessageParser.cs
csharp/src/Google.Protobuf/MessageParser.cs
+0
-12
ExtensionCollection.cs
csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs
+5
-4
No files found.
csharp/src/Google.Protobuf.Test/GeneratedMessageTest.Proto2.cs
View file @
20b7fab0
...
...
@@ -261,6 +261,18 @@ namespace Google.Protobuf
Assert
.
True
(
message
.
IsInitialized
());
}
/// <summary>
/// Code was accidentally left in message parser that threw exceptions when missing required fields after parsing.
/// We've decided to not throw exceptions on missing fields, instead leaving it up to the consumer how they
/// want to check and handle missing fields.
/// </summary>
[
Test
]
public
void
RequiredFieldsNoThrow
()
{
Assert
.
DoesNotThrow
(()
=>
TestRequired
.
Parser
.
ParseFrom
(
new
byte
[
0
]));
Assert
.
DoesNotThrow
(()
=>
(
TestRequired
.
Parser
as
MessageParser
).
ParseFrom
(
new
byte
[
0
]));
}
[
Test
]
public
void
RequiredFieldsInExtensions
()
{
...
...
csharp/src/Google.Protobuf/CodedOutputStream.cs
View file @
20b7fab0
...
...
@@ -89,7 +89,7 @@ namespace Google.Protobuf
private
CodedOutputStream
(
byte
[]
buffer
,
int
offset
,
int
length
)
{
this
.
output
=
null
;
this
.
buffer
=
buffer
;
this
.
buffer
=
ProtoPreconditions
.
CheckNotNull
(
buffer
,
nameof
(
buffer
))
;
this
.
position
=
offset
;
this
.
limit
=
offset
+
length
;
leaveOpen
=
true
;
// Simple way of avoiding trying to dispose of a null reference
...
...
csharp/src/Google.Protobuf/JsonFormatter.cs
View file @
20b7fab0
...
...
@@ -133,7 +133,7 @@ namespace Google.Protobuf
/// <param name="settings">The settings.</param>
public
JsonFormatter
(
Settings
settings
)
{
this
.
settings
=
settings
;
this
.
settings
=
ProtoPreconditions
.
CheckNotNull
(
settings
,
nameof
(
settings
))
;
}
/// <summary>
...
...
csharp/src/Google.Protobuf/JsonParser.cs
View file @
20b7fab0
...
...
@@ -110,7 +110,7 @@ namespace Google.Protobuf
/// <param name="settings">The settings.</param>
public
JsonParser
(
Settings
settings
)
{
this
.
settings
=
settings
;
this
.
settings
=
ProtoPreconditions
.
CheckNotNull
(
settings
,
nameof
(
settings
))
;
}
/// <summary>
...
...
csharp/src/Google.Protobuf/MessageParser.cs
View file @
20b7fab0
...
...
@@ -72,7 +72,6 @@ namespace Google.Protobuf
{
IMessage
message
=
factory
();
message
.
MergeFrom
(
data
,
DiscardUnknownFields
,
Extensions
);
CheckMergedRequiredFields
(
message
);
return
message
;
}
...
...
@@ -87,7 +86,6 @@ namespace Google.Protobuf
{
IMessage
message
=
factory
();
message
.
MergeFrom
(
data
,
offset
,
length
,
DiscardUnknownFields
,
Extensions
);
CheckMergedRequiredFields
(
message
);
return
message
;
}
...
...
@@ -100,7 +98,6 @@ namespace Google.Protobuf
{
IMessage
message
=
factory
();
message
.
MergeFrom
(
data
,
DiscardUnknownFields
,
Extensions
);
CheckMergedRequiredFields
(
message
);
return
message
;
}
...
...
@@ -113,7 +110,6 @@ namespace Google.Protobuf
{
IMessage
message
=
factory
();
message
.
MergeFrom
(
input
,
DiscardUnknownFields
,
Extensions
);
CheckMergedRequiredFields
(
message
);
return
message
;
}
...
...
@@ -130,7 +126,6 @@ namespace Google.Protobuf
{
IMessage
message
=
factory
();
message
.
MergeDelimitedFrom
(
input
,
DiscardUnknownFields
,
Extensions
);
CheckMergedRequiredFields
(
message
);
return
message
;
}
...
...
@@ -143,7 +138,6 @@ namespace Google.Protobuf
{
IMessage
message
=
factory
();
MergeFrom
(
message
,
input
);
CheckMergedRequiredFields
(
message
);
return
message
;
}
...
...
@@ -176,12 +170,6 @@ namespace Google.Protobuf
}
}
internal
static
void
CheckMergedRequiredFields
(
IMessage
message
)
{
if
(!
message
.
IsInitialized
())
throw
new
InvalidOperationException
(
"Parsed message does not contain all required fields"
);
}
/// <summary>
/// Creates a new message parser which optionally discards unknown fields when parsing.
/// </summary>
...
...
csharp/src/Google.Protobuf/Reflection/ExtensionCollection.cs
View file @
20b7fab0
...
...
@@ -107,13 +107,14 @@ namespace Google.Protobuf.Reflection
{
descriptor
.
CrossLink
();
IList
<
FieldDescriptor
>
_
;
if
(!
declarationOrder
.
TryGetValue
(
descriptor
.
ExtendeeType
,
out
_
))
IList
<
FieldDescriptor
>
list
;
if
(!
declarationOrder
.
TryGetValue
(
descriptor
.
ExtendeeType
,
out
list
))
{
declarationOrder
.
Add
(
descriptor
.
ExtendeeType
,
new
List
<
FieldDescriptor
>());
list
=
new
List
<
FieldDescriptor
>();
declarationOrder
.
Add
(
descriptor
.
ExtendeeType
,
list
);
}
declarationOrder
[
descriptor
.
ExtendeeType
]
.
Add
(
descriptor
);
list
.
Add
(
descriptor
);
}
extensionsByTypeInDeclarationOrder
=
declarationOrder
...
...
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