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
7762f163
Commit
7762f163
authored
Feb 04, 2016
by
Jon Skeet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename Preconditions to ProtoPreconditions
(Generated code changes in next commit.)
parent
c78222a3
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
94 additions
and
89 deletions
+94
-89
Makefile.am
Makefile.am
+1
-1
CodedInputStream.cs
csharp/src/Google.Protobuf/CodedInputStream.cs
+3
-3
MapField.cs
csharp/src/Google.Protobuf/Collections/MapField.cs
+8
-8
Google.Protobuf.csproj
csharp/src/Google.Protobuf/Google.Protobuf.csproj
+1
-1
JsonFormatter.cs
csharp/src/Google.Protobuf/JsonFormatter.cs
+3
-3
JsonParser.cs
csharp/src/Google.Protobuf/JsonParser.cs
+7
-7
MessageExtensions.cs
csharp/src/Google.Protobuf/MessageExtensions.cs
+14
-14
MessageParser.cs
csharp/src/Google.Protobuf/MessageParser.cs
+4
-4
ProtoPreconditions.cs
csharp/src/Google.Protobuf/ProtoPreconditions.cs
+7
-2
Descriptor.cs
csharp/src/Google.Protobuf/Reflection/Descriptor.cs
+27
-27
TypeRegistry.cs
csharp/src/Google.Protobuf/Reflection/TypeRegistry.cs
+2
-2
AnyPartial.cs
csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs
+1
-1
DurationPartial.cs
csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs
+5
-5
TimestampPartial.cs
...rp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs
+6
-6
ValuePartial.cs
csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs
+3
-3
csharp_primitive_field.cc
...google/protobuf/compiler/csharp/csharp_primitive_field.cc
+2
-2
No files found.
Makefile.am
View file @
7762f163
...
@@ -133,7 +133,7 @@ csharp_EXTRA_DIST= \
...
@@ -133,7 +133,7 @@ csharp_EXTRA_DIST= \
csharp/src/Google.Protobuf/LimitedInputStream.cs
\
csharp/src/Google.Protobuf/LimitedInputStream.cs
\
csharp/src/Google.Protobuf/MessageExtensions.cs
\
csharp/src/Google.Protobuf/MessageExtensions.cs
\
csharp/src/Google.Protobuf/MessageParser.cs
\
csharp/src/Google.Protobuf/MessageParser.cs
\
csharp/src/Google.Protobuf/Pr
econditions.cs
\
csharp/src/Google.Protobuf/Pr
otoPreconditions.cs
\
csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs
\
csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs
\
csharp/src/Google.Protobuf/Reflection/Descriptor.cs
\
csharp/src/Google.Protobuf/Reflection/Descriptor.cs
\
csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs
\
csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs
\
...
...
csharp/src/Google.Protobuf/CodedInputStream.cs
View file @
7762f163
...
@@ -115,7 +115,7 @@ namespace Google.Protobuf
...
@@ -115,7 +115,7 @@ namespace Google.Protobuf
/// <summary>
/// <summary>
/// Creates a new CodedInputStream reading data from the given byte array.
/// Creates a new CodedInputStream reading data from the given byte array.
/// </summary>
/// </summary>
public
CodedInputStream
(
byte
[]
buffer
)
:
this
(
null
,
Preconditions
.
CheckNotNull
(
buffer
,
"buffer"
),
0
,
buffer
.
Length
)
public
CodedInputStream
(
byte
[]
buffer
)
:
this
(
null
,
Pr
otoPr
econditions
.
CheckNotNull
(
buffer
,
"buffer"
),
0
,
buffer
.
Length
)
{
{
}
}
...
@@ -123,7 +123,7 @@ namespace Google.Protobuf
...
@@ -123,7 +123,7 @@ namespace Google.Protobuf
/// Creates a new CodedInputStream that reads from the given byte array slice.
/// Creates a new CodedInputStream that reads from the given byte array slice.
/// </summary>
/// </summary>
public
CodedInputStream
(
byte
[]
buffer
,
int
offset
,
int
length
)
public
CodedInputStream
(
byte
[]
buffer
,
int
offset
,
int
length
)
:
this
(
null
,
Preconditions
.
CheckNotNull
(
buffer
,
"buffer"
),
offset
,
offset
+
length
)
:
this
(
null
,
Pr
otoPr
econditions
.
CheckNotNull
(
buffer
,
"buffer"
),
offset
,
offset
+
length
)
{
{
if
(
offset
<
0
||
offset
>
buffer
.
Length
)
if
(
offset
<
0
||
offset
>
buffer
.
Length
)
{
{
...
@@ -140,7 +140,7 @@ namespace Google.Protobuf
...
@@ -140,7 +140,7 @@ namespace Google.Protobuf
/// </summary>
/// </summary>
public
CodedInputStream
(
Stream
input
)
:
this
(
input
,
new
byte
[
BufferSize
],
0
,
0
)
public
CodedInputStream
(
Stream
input
)
:
this
(
input
,
new
byte
[
BufferSize
],
0
,
0
)
{
{
Preconditions
.
CheckNotNull
(
input
,
"input"
);
Pr
otoPr
econditions
.
CheckNotNull
(
input
,
"input"
);
}
}
/// <summary>
/// <summary>
...
...
csharp/src/Google.Protobuf/Collections/MapField.cs
View file @
7762f163
...
@@ -123,7 +123,7 @@ namespace Google.Protobuf.Collections
...
@@ -123,7 +123,7 @@ namespace Google.Protobuf.Collections
/// <returns><c>true</c> if the map contains the given key; <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if the map contains the given key; <c>false</c> otherwise.</returns>
public
bool
ContainsKey
(
TKey
key
)
public
bool
ContainsKey
(
TKey
key
)
{
{
Preconditions
.
CheckNotNullUnconstrained
(
key
,
"key"
);
Pr
otoPr
econditions
.
CheckNotNullUnconstrained
(
key
,
"key"
);
return
map
.
ContainsKey
(
key
);
return
map
.
ContainsKey
(
key
);
}
}
...
@@ -140,7 +140,7 @@ namespace Google.Protobuf.Collections
...
@@ -140,7 +140,7 @@ namespace Google.Protobuf.Collections
/// <returns><c>true</c> if the map contained the given key before the entry was removed; <c>false</c> otherwise.</returns>
/// <returns><c>true</c> if the map contained the given key before the entry was removed; <c>false</c> otherwise.</returns>
public
bool
Remove
(
TKey
key
)
public
bool
Remove
(
TKey
key
)
{
{
Preconditions
.
CheckNotNullUnconstrained
(
key
,
"key"
);
Pr
otoPr
econditions
.
CheckNotNullUnconstrained
(
key
,
"key"
);
LinkedListNode
<
KeyValuePair
<
TKey
,
TValue
>>
node
;
LinkedListNode
<
KeyValuePair
<
TKey
,
TValue
>>
node
;
if
(
map
.
TryGetValue
(
key
,
out
node
))
if
(
map
.
TryGetValue
(
key
,
out
node
))
{
{
...
@@ -188,7 +188,7 @@ namespace Google.Protobuf.Collections
...
@@ -188,7 +188,7 @@ namespace Google.Protobuf.Collections
{
{
get
get
{
{
Preconditions
.
CheckNotNullUnconstrained
(
key
,
"key"
);
Pr
otoPr
econditions
.
CheckNotNullUnconstrained
(
key
,
"key"
);
TValue
value
;
TValue
value
;
if
(
TryGetValue
(
key
,
out
value
))
if
(
TryGetValue
(
key
,
out
value
))
{
{
...
@@ -198,11 +198,11 @@ namespace Google.Protobuf.Collections
...
@@ -198,11 +198,11 @@ namespace Google.Protobuf.Collections
}
}
set
set
{
{
Preconditions
.
CheckNotNullUnconstrained
(
key
,
"key"
);
Pr
otoPr
econditions
.
CheckNotNullUnconstrained
(
key
,
"key"
);
// value == null check here is redundant, but avoids boxing.
// value == null check here is redundant, but avoids boxing.
if
(
value
==
null
)
if
(
value
==
null
)
{
{
Preconditions
.
CheckNotNullUnconstrained
(
value
,
"value"
);
Pr
otoPr
econditions
.
CheckNotNullUnconstrained
(
value
,
"value"
);
}
}
LinkedListNode
<
KeyValuePair
<
TKey
,
TValue
>>
node
;
LinkedListNode
<
KeyValuePair
<
TKey
,
TValue
>>
node
;
var
pair
=
new
KeyValuePair
<
TKey
,
TValue
>(
key
,
value
);
var
pair
=
new
KeyValuePair
<
TKey
,
TValue
>(
key
,
value
);
...
@@ -234,7 +234,7 @@ namespace Google.Protobuf.Collections
...
@@ -234,7 +234,7 @@ namespace Google.Protobuf.Collections
/// <param name="entries">The entries to add to the map.</param>
/// <param name="entries">The entries to add to the map.</param>
public
void
Add
(
IDictionary
<
TKey
,
TValue
>
entries
)
public
void
Add
(
IDictionary
<
TKey
,
TValue
>
entries
)
{
{
Preconditions
.
CheckNotNull
(
entries
,
"entries"
);
Pr
otoPr
econditions
.
CheckNotNull
(
entries
,
"entries"
);
foreach
(
var
pair
in
entries
)
foreach
(
var
pair
in
entries
)
{
{
Add
(
pair
.
Key
,
pair
.
Value
);
Add
(
pair
.
Key
,
pair
.
Value
);
...
@@ -501,7 +501,7 @@ namespace Google.Protobuf.Collections
...
@@ -501,7 +501,7 @@ namespace Google.Protobuf.Collections
void
IDictionary
.
Remove
(
object
key
)
void
IDictionary
.
Remove
(
object
key
)
{
{
Preconditions
.
CheckNotNull
(
key
,
"key"
);
Pr
otoPr
econditions
.
CheckNotNull
(
key
,
"key"
);
if
(!(
key
is
TKey
))
if
(!(
key
is
TKey
))
{
{
return
;
return
;
...
@@ -530,7 +530,7 @@ namespace Google.Protobuf.Collections
...
@@ -530,7 +530,7 @@ namespace Google.Protobuf.Collections
{
{
get
get
{
{
Preconditions
.
CheckNotNull
(
key
,
"key"
);
Pr
otoPr
econditions
.
CheckNotNull
(
key
,
"key"
);
if
(!(
key
is
TKey
))
if
(!(
key
is
TKey
))
{
{
return
null
;
return
null
;
...
...
csharp/src/Google.Protobuf/Google.Protobuf.csproj
View file @
7762f163
...
@@ -123,7 +123,7 @@
...
@@ -123,7 +123,7 @@
<Compile
Include=
"Reflection\RepeatedFieldAccessor.cs"
/>
<Compile
Include=
"Reflection\RepeatedFieldAccessor.cs"
/>
<Compile
Include=
"Reflection\ServiceDescriptor.cs"
/>
<Compile
Include=
"Reflection\ServiceDescriptor.cs"
/>
<Compile
Include=
"Reflection\SingleFieldAccessor.cs"
/>
<Compile
Include=
"Reflection\SingleFieldAccessor.cs"
/>
<Compile
Include=
"Preconditions.cs"
/>
<Compile
Include=
"Pr
otoPr
econditions.cs"
/>
<Compile
Include=
"Reflection\TypeRegistry.cs"
/>
<Compile
Include=
"Reflection\TypeRegistry.cs"
/>
<Compile
Include=
"WellKnownTypes\Any.cs"
/>
<Compile
Include=
"WellKnownTypes\Any.cs"
/>
<Compile
Include=
"WellKnownTypes\AnyPartial.cs"
/>
<Compile
Include=
"WellKnownTypes\AnyPartial.cs"
/>
...
...
csharp/src/Google.Protobuf/JsonFormatter.cs
View file @
7762f163
...
@@ -141,7 +141,7 @@ namespace Google.Protobuf
...
@@ -141,7 +141,7 @@ namespace Google.Protobuf
/// <returns>The formatted message.</returns>
/// <returns>The formatted message.</returns>
public
string
Format
(
IMessage
message
)
public
string
Format
(
IMessage
message
)
{
{
Preconditions
.
CheckNotNull
(
message
,
nameof
(
message
));
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
nameof
(
message
));
StringBuilder
builder
=
new
StringBuilder
();
StringBuilder
builder
=
new
StringBuilder
();
if
(
message
.
Descriptor
.
IsWellKnownType
)
if
(
message
.
Descriptor
.
IsWellKnownType
)
{
{
...
@@ -173,7 +173,7 @@ namespace Google.Protobuf
...
@@ -173,7 +173,7 @@ namespace Google.Protobuf
/// <returns>The diagnostic-only JSON representation of the message</returns>
/// <returns>The diagnostic-only JSON representation of the message</returns>
public
static
string
ToDiagnosticString
(
IMessage
message
)
public
static
string
ToDiagnosticString
(
IMessage
message
)
{
{
Preconditions
.
CheckNotNull
(
message
,
nameof
(
message
));
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
nameof
(
message
));
return
diagnosticFormatter
.
Format
(
message
);
return
diagnosticFormatter
.
Format
(
message
);
}
}
...
@@ -858,7 +858,7 @@ namespace Google.Protobuf
...
@@ -858,7 +858,7 @@ namespace Google.Protobuf
public
Settings
(
bool
formatDefaultValues
,
TypeRegistry
typeRegistry
)
public
Settings
(
bool
formatDefaultValues
,
TypeRegistry
typeRegistry
)
{
{
FormatDefaultValues
=
formatDefaultValues
;
FormatDefaultValues
=
formatDefaultValues
;
TypeRegistry
=
Preconditions
.
CheckNotNull
(
typeRegistry
,
nameof
(
typeRegistry
));
TypeRegistry
=
Pr
otoPr
econditions
.
CheckNotNull
(
typeRegistry
,
nameof
(
typeRegistry
));
}
}
}
}
}
}
...
...
csharp/src/Google.Protobuf/JsonParser.cs
View file @
7762f163
...
@@ -374,7 +374,7 @@ namespace Google.Protobuf
...
@@ -374,7 +374,7 @@ namespace Google.Protobuf
/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffers message correctly</exception>
/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffers message correctly</exception>
public
T
Parse
<
T
>(
string
json
)
where
T
:
IMessage
,
new
()
public
T
Parse
<
T
>(
string
json
)
where
T
:
IMessage
,
new
()
{
{
Preconditions
.
CheckNotNull
(
json
,
nameof
(
json
));
Pr
otoPr
econditions
.
CheckNotNull
(
json
,
nameof
(
json
));
return
Parse
<
T
>(
new
StringReader
(
json
));
return
Parse
<
T
>(
new
StringReader
(
json
));
}
}
...
@@ -387,7 +387,7 @@ namespace Google.Protobuf
...
@@ -387,7 +387,7 @@ namespace Google.Protobuf
/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffers message correctly</exception>
/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffers message correctly</exception>
public
T
Parse
<
T
>(
TextReader
jsonReader
)
where
T
:
IMessage
,
new
()
public
T
Parse
<
T
>(
TextReader
jsonReader
)
where
T
:
IMessage
,
new
()
{
{
Preconditions
.
CheckNotNull
(
jsonReader
,
nameof
(
jsonReader
));
Pr
otoPr
econditions
.
CheckNotNull
(
jsonReader
,
nameof
(
jsonReader
));
T
message
=
new
T
();
T
message
=
new
T
();
Merge
(
message
,
jsonReader
);
Merge
(
message
,
jsonReader
);
return
message
;
return
message
;
...
@@ -402,8 +402,8 @@ namespace Google.Protobuf
...
@@ -402,8 +402,8 @@ namespace Google.Protobuf
/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffers message correctly</exception>
/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffers message correctly</exception>
public
IMessage
Parse
(
string
json
,
MessageDescriptor
descriptor
)
public
IMessage
Parse
(
string
json
,
MessageDescriptor
descriptor
)
{
{
Preconditions
.
CheckNotNull
(
json
,
nameof
(
json
));
Pr
otoPr
econditions
.
CheckNotNull
(
json
,
nameof
(
json
));
Preconditions
.
CheckNotNull
(
descriptor
,
nameof
(
descriptor
));
Pr
otoPr
econditions
.
CheckNotNull
(
descriptor
,
nameof
(
descriptor
));
return
Parse
(
new
StringReader
(
json
),
descriptor
);
return
Parse
(
new
StringReader
(
json
),
descriptor
);
}
}
...
@@ -416,8 +416,8 @@ namespace Google.Protobuf
...
@@ -416,8 +416,8 @@ namespace Google.Protobuf
/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffers message correctly</exception>
/// <exception cref="InvalidProtocolBufferException">The JSON does not represent a Protocol Buffers message correctly</exception>
public
IMessage
Parse
(
TextReader
jsonReader
,
MessageDescriptor
descriptor
)
public
IMessage
Parse
(
TextReader
jsonReader
,
MessageDescriptor
descriptor
)
{
{
Preconditions
.
CheckNotNull
(
jsonReader
,
nameof
(
jsonReader
));
Pr
otoPr
econditions
.
CheckNotNull
(
jsonReader
,
nameof
(
jsonReader
));
Preconditions
.
CheckNotNull
(
descriptor
,
nameof
(
descriptor
));
Pr
otoPr
econditions
.
CheckNotNull
(
descriptor
,
nameof
(
descriptor
));
IMessage
message
=
descriptor
.
Parser
.
CreateTemplate
();
IMessage
message
=
descriptor
.
Parser
.
CreateTemplate
();
Merge
(
message
,
jsonReader
);
Merge
(
message
,
jsonReader
);
return
message
;
return
message
;
...
@@ -1011,7 +1011,7 @@ namespace Google.Protobuf
...
@@ -1011,7 +1011,7 @@ namespace Google.Protobuf
public
Settings
(
int
recursionLimit
,
TypeRegistry
typeRegistry
)
public
Settings
(
int
recursionLimit
,
TypeRegistry
typeRegistry
)
{
{
RecursionLimit
=
recursionLimit
;
RecursionLimit
=
recursionLimit
;
TypeRegistry
=
Preconditions
.
CheckNotNull
(
typeRegistry
,
nameof
(
typeRegistry
));
TypeRegistry
=
Pr
otoPr
econditions
.
CheckNotNull
(
typeRegistry
,
nameof
(
typeRegistry
));
}
}
}
}
}
}
...
...
csharp/src/Google.Protobuf/MessageExtensions.cs
View file @
7762f163
...
@@ -46,8 +46,8 @@ namespace Google.Protobuf
...
@@ -46,8 +46,8 @@ namespace Google.Protobuf
/// <param name="data">The data to merge, which must be protobuf-encoded binary data.</param>
/// <param name="data">The data to merge, which must be protobuf-encoded binary data.</param>
public
static
void
MergeFrom
(
this
IMessage
message
,
byte
[]
data
)
public
static
void
MergeFrom
(
this
IMessage
message
,
byte
[]
data
)
{
{
Preconditions
.
CheckNotNull
(
message
,
"message"
);
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
"message"
);
Preconditions
.
CheckNotNull
(
data
,
"data"
);
Pr
otoPr
econditions
.
CheckNotNull
(
data
,
"data"
);
CodedInputStream
input
=
new
CodedInputStream
(
data
);
CodedInputStream
input
=
new
CodedInputStream
(
data
);
message
.
MergeFrom
(
input
);
message
.
MergeFrom
(
input
);
input
.
CheckReadEndOfStreamTag
();
input
.
CheckReadEndOfStreamTag
();
...
@@ -60,8 +60,8 @@ namespace Google.Protobuf
...
@@ -60,8 +60,8 @@ namespace Google.Protobuf
/// <param name="data">The data to merge, which must be protobuf-encoded binary data.</param>
/// <param name="data">The data to merge, which must be protobuf-encoded binary data.</param>
public
static
void
MergeFrom
(
this
IMessage
message
,
ByteString
data
)
public
static
void
MergeFrom
(
this
IMessage
message
,
ByteString
data
)
{
{
Preconditions
.
CheckNotNull
(
message
,
"message"
);
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
"message"
);
Preconditions
.
CheckNotNull
(
data
,
"data"
);
Pr
otoPr
econditions
.
CheckNotNull
(
data
,
"data"
);
CodedInputStream
input
=
data
.
CreateCodedInput
();
CodedInputStream
input
=
data
.
CreateCodedInput
();
message
.
MergeFrom
(
input
);
message
.
MergeFrom
(
input
);
input
.
CheckReadEndOfStreamTag
();
input
.
CheckReadEndOfStreamTag
();
...
@@ -74,8 +74,8 @@ namespace Google.Protobuf
...
@@ -74,8 +74,8 @@ namespace Google.Protobuf
/// <param name="input">Stream containing the data to merge, which must be protobuf-encoded binary data.</param>
/// <param name="input">Stream containing the data to merge, which must be protobuf-encoded binary data.</param>
public
static
void
MergeFrom
(
this
IMessage
message
,
Stream
input
)
public
static
void
MergeFrom
(
this
IMessage
message
,
Stream
input
)
{
{
Preconditions
.
CheckNotNull
(
message
,
"message"
);
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
"message"
);
Preconditions
.
CheckNotNull
(
input
,
"input"
);
Pr
otoPr
econditions
.
CheckNotNull
(
input
,
"input"
);
CodedInputStream
codedInput
=
new
CodedInputStream
(
input
);
CodedInputStream
codedInput
=
new
CodedInputStream
(
input
);
message
.
MergeFrom
(
codedInput
);
message
.
MergeFrom
(
codedInput
);
codedInput
.
CheckReadEndOfStreamTag
();
codedInput
.
CheckReadEndOfStreamTag
();
...
@@ -92,8 +92,8 @@ namespace Google.Protobuf
...
@@ -92,8 +92,8 @@ namespace Google.Protobuf
/// <param name="input">Stream containing the data to merge, which must be protobuf-encoded binary data.</param>
/// <param name="input">Stream containing the data to merge, which must be protobuf-encoded binary data.</param>
public
static
void
MergeDelimitedFrom
(
this
IMessage
message
,
Stream
input
)
public
static
void
MergeDelimitedFrom
(
this
IMessage
message
,
Stream
input
)
{
{
Preconditions
.
CheckNotNull
(
message
,
"message"
);
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
"message"
);
Preconditions
.
CheckNotNull
(
input
,
"input"
);
Pr
otoPr
econditions
.
CheckNotNull
(
input
,
"input"
);
int
size
=
(
int
)
CodedInputStream
.
ReadRawVarint32
(
input
);
int
size
=
(
int
)
CodedInputStream
.
ReadRawVarint32
(
input
);
Stream
limitedStream
=
new
LimitedInputStream
(
input
,
size
);
Stream
limitedStream
=
new
LimitedInputStream
(
input
,
size
);
message
.
MergeFrom
(
limitedStream
);
message
.
MergeFrom
(
limitedStream
);
...
@@ -106,7 +106,7 @@ namespace Google.Protobuf
...
@@ -106,7 +106,7 @@ namespace Google.Protobuf
/// <returns>The message data as a byte array.</returns>
/// <returns>The message data as a byte array.</returns>
public
static
byte
[]
ToByteArray
(
this
IMessage
message
)
public
static
byte
[]
ToByteArray
(
this
IMessage
message
)
{
{
Preconditions
.
CheckNotNull
(
message
,
"message"
);
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
"message"
);
byte
[]
result
=
new
byte
[
message
.
CalculateSize
()];
byte
[]
result
=
new
byte
[
message
.
CalculateSize
()];
CodedOutputStream
output
=
new
CodedOutputStream
(
result
);
CodedOutputStream
output
=
new
CodedOutputStream
(
result
);
message
.
WriteTo
(
output
);
message
.
WriteTo
(
output
);
...
@@ -121,8 +121,8 @@ namespace Google.Protobuf
...
@@ -121,8 +121,8 @@ namespace Google.Protobuf
/// <param name="output">The stream to write to.</param>
/// <param name="output">The stream to write to.</param>
public
static
void
WriteTo
(
this
IMessage
message
,
Stream
output
)
public
static
void
WriteTo
(
this
IMessage
message
,
Stream
output
)
{
{
Preconditions
.
CheckNotNull
(
message
,
"message"
);
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
"message"
);
Preconditions
.
CheckNotNull
(
output
,
"output"
);
Pr
otoPr
econditions
.
CheckNotNull
(
output
,
"output"
);
CodedOutputStream
codedOutput
=
new
CodedOutputStream
(
output
);
CodedOutputStream
codedOutput
=
new
CodedOutputStream
(
output
);
message
.
WriteTo
(
codedOutput
);
message
.
WriteTo
(
codedOutput
);
codedOutput
.
Flush
();
codedOutput
.
Flush
();
...
@@ -135,8 +135,8 @@ namespace Google.Protobuf
...
@@ -135,8 +135,8 @@ namespace Google.Protobuf
/// <param name="output">The output stream to write to.</param>
/// <param name="output">The output stream to write to.</param>
public
static
void
WriteDelimitedTo
(
this
IMessage
message
,
Stream
output
)
public
static
void
WriteDelimitedTo
(
this
IMessage
message
,
Stream
output
)
{
{
Preconditions
.
CheckNotNull
(
message
,
"message"
);
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
"message"
);
Preconditions
.
CheckNotNull
(
output
,
"output"
);
Pr
otoPr
econditions
.
CheckNotNull
(
output
,
"output"
);
CodedOutputStream
codedOutput
=
new
CodedOutputStream
(
output
);
CodedOutputStream
codedOutput
=
new
CodedOutputStream
(
output
);
codedOutput
.
WriteRawVarint32
((
uint
)
message
.
CalculateSize
());
codedOutput
.
WriteRawVarint32
((
uint
)
message
.
CalculateSize
());
message
.
WriteTo
(
codedOutput
);
message
.
WriteTo
(
codedOutput
);
...
@@ -150,7 +150,7 @@ namespace Google.Protobuf
...
@@ -150,7 +150,7 @@ namespace Google.Protobuf
/// <returns>The message data as a byte string.</returns>
/// <returns>The message data as a byte string.</returns>
public
static
ByteString
ToByteString
(
this
IMessage
message
)
public
static
ByteString
ToByteString
(
this
IMessage
message
)
{
{
Preconditions
.
CheckNotNull
(
message
,
"message"
);
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
"message"
);
return
ByteString
.
AttachBytes
(
message
.
ToByteArray
());
return
ByteString
.
AttachBytes
(
message
.
ToByteArray
());
}
}
}
}
...
...
csharp/src/Google.Protobuf/MessageParser.cs
View file @
7762f163
...
@@ -64,7 +64,7 @@ namespace Google.Protobuf
...
@@ -64,7 +64,7 @@ namespace Google.Protobuf
/// <returns>The newly parsed message.</returns>
/// <returns>The newly parsed message.</returns>
public
IMessage
ParseFrom
(
byte
[]
data
)
public
IMessage
ParseFrom
(
byte
[]
data
)
{
{
Preconditions
.
CheckNotNull
(
data
,
"data"
);
Pr
otoPr
econditions
.
CheckNotNull
(
data
,
"data"
);
IMessage
message
=
factory
();
IMessage
message
=
factory
();
message
.
MergeFrom
(
data
);
message
.
MergeFrom
(
data
);
return
message
;
return
message
;
...
@@ -77,7 +77,7 @@ namespace Google.Protobuf
...
@@ -77,7 +77,7 @@ namespace Google.Protobuf
/// <returns>The parsed message.</returns>
/// <returns>The parsed message.</returns>
public
IMessage
ParseFrom
(
ByteString
data
)
public
IMessage
ParseFrom
(
ByteString
data
)
{
{
Preconditions
.
CheckNotNull
(
data
,
"data"
);
Pr
otoPr
econditions
.
CheckNotNull
(
data
,
"data"
);
IMessage
message
=
factory
();
IMessage
message
=
factory
();
message
.
MergeFrom
(
data
);
message
.
MergeFrom
(
data
);
return
message
;
return
message
;
...
@@ -191,7 +191,7 @@ namespace Google.Protobuf
...
@@ -191,7 +191,7 @@ namespace Google.Protobuf
/// <returns>The newly parsed message.</returns>
/// <returns>The newly parsed message.</returns>
public
new
T
ParseFrom
(
byte
[]
data
)
public
new
T
ParseFrom
(
byte
[]
data
)
{
{
Preconditions
.
CheckNotNull
(
data
,
"data"
);
Pr
otoPr
econditions
.
CheckNotNull
(
data
,
"data"
);
T
message
=
factory
();
T
message
=
factory
();
message
.
MergeFrom
(
data
);
message
.
MergeFrom
(
data
);
return
message
;
return
message
;
...
@@ -204,7 +204,7 @@ namespace Google.Protobuf
...
@@ -204,7 +204,7 @@ namespace Google.Protobuf
/// <returns>The parsed message.</returns>
/// <returns>The parsed message.</returns>
public
new
T
ParseFrom
(
ByteString
data
)
public
new
T
ParseFrom
(
ByteString
data
)
{
{
Preconditions
.
CheckNotNull
(
data
,
"data"
);
Pr
otoPr
econditions
.
CheckNotNull
(
data
,
"data"
);
T
message
=
factory
();
T
message
=
factory
();
message
.
MergeFrom
(
data
);
message
.
MergeFrom
(
data
);
return
message
;
return
message
;
...
...
csharp/src/Google.Protobuf/Preconditions.cs
→
csharp/src/Google.Protobuf/Pr
otoPr
econditions.cs
View file @
7762f163
...
@@ -35,9 +35,14 @@ using System;
...
@@ -35,9 +35,14 @@ using System;
namespace
Google.Protobuf
namespace
Google.Protobuf
{
{
/// <summary>
/// <summary>
/// Helper methods for throwing exceptions
/// Helper methods for throwing exceptions
when preconditions are not met.
/// </summary>
/// </summary>
public
static
class
Preconditions
/// <remarks>
/// This class is used internally and by generated code; it is not particularly
/// expected to be used from application code, although nothing prevents it
/// from being used that way.
/// </remarks>
public
static
class
ProtoPreconditions
{
{
/// <summary>
/// <summary>
/// Throws an ArgumentNullException if the given value is null, otherwise
/// Throws an ArgumentNullException if the given value is null, otherwise
...
...
csharp/src/Google.Protobuf/Reflection/Descriptor.cs
View file @
7762f163
...
@@ -317,7 +317,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -317,7 +317,7 @@ namespace Google.Protobuf.Reflection {
public
string
Name
{
public
string
Name
{
get
{
return
name_
;
}
get
{
return
name_
;
}
set
{
set
{
name_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
name_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -330,7 +330,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -330,7 +330,7 @@ namespace Google.Protobuf.Reflection {
public
string
Package
{
public
string
Package
{
get
{
return
package_
;
}
get
{
return
package_
;
}
set
{
set
{
package_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
package_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -446,7 +446,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -446,7 +446,7 @@ namespace Google.Protobuf.Reflection {
public
string
Syntax
{
public
string
Syntax
{
get
{
return
syntax_
;
}
get
{
return
syntax_
;
}
set
{
set
{
syntax_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
syntax_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -702,7 +702,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -702,7 +702,7 @@ namespace Google.Protobuf.Reflection {
public
string
Name
{
public
string
Name
{
get
{
return
name_
;
}
get
{
return
name_
;
}
set
{
set
{
name_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
name_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -1275,7 +1275,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -1275,7 +1275,7 @@ namespace Google.Protobuf.Reflection {
public
string
Name
{
public
string
Name
{
get
{
return
name_
;
}
get
{
return
name_
;
}
set
{
set
{
name_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
name_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -1326,7 +1326,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -1326,7 +1326,7 @@ namespace Google.Protobuf.Reflection {
public
string
TypeName
{
public
string
TypeName
{
get
{
return
typeName_
;
}
get
{
return
typeName_
;
}
set
{
set
{
typeName_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
typeName_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -1340,7 +1340,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -1340,7 +1340,7 @@ namespace Google.Protobuf.Reflection {
public
string
Extendee
{
public
string
Extendee
{
get
{
return
extendee_
;
}
get
{
return
extendee_
;
}
set
{
set
{
extendee_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
extendee_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -1357,7 +1357,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -1357,7 +1357,7 @@ namespace Google.Protobuf.Reflection {
public
string
DefaultValue
{
public
string
DefaultValue
{
get
{
return
defaultValue_
;
}
get
{
return
defaultValue_
;
}
set
{
set
{
defaultValue_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
defaultValue_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -1387,7 +1387,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -1387,7 +1387,7 @@ namespace Google.Protobuf.Reflection {
public
string
JsonName
{
public
string
JsonName
{
get
{
return
jsonName_
;
}
get
{
return
jsonName_
;
}
set
{
set
{
jsonName_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
jsonName_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -1720,7 +1720,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -1720,7 +1720,7 @@ namespace Google.Protobuf.Reflection {
public
string
Name
{
public
string
Name
{
get
{
return
name_
;
}
get
{
return
name_
;
}
set
{
set
{
name_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
name_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -1828,7 +1828,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -1828,7 +1828,7 @@ namespace Google.Protobuf.Reflection {
public
string
Name
{
public
string
Name
{
get
{
return
name_
;
}
get
{
return
name_
;
}
set
{
set
{
name_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
name_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -1986,7 +1986,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -1986,7 +1986,7 @@ namespace Google.Protobuf.Reflection {
public
string
Name
{
public
string
Name
{
get
{
return
name_
;
}
get
{
return
name_
;
}
set
{
set
{
name_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
name_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -2152,7 +2152,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -2152,7 +2152,7 @@ namespace Google.Protobuf.Reflection {
public
string
Name
{
public
string
Name
{
get
{
return
name_
;
}
get
{
return
name_
;
}
set
{
set
{
name_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
name_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -2313,7 +2313,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -2313,7 +2313,7 @@ namespace Google.Protobuf.Reflection {
public
string
Name
{
public
string
Name
{
get
{
return
name_
;
}
get
{
return
name_
;
}
set
{
set
{
name_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
name_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -2327,7 +2327,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -2327,7 +2327,7 @@ namespace Google.Protobuf.Reflection {
public
string
InputType
{
public
string
InputType
{
get
{
return
inputType_
;
}
get
{
return
inputType_
;
}
set
{
set
{
inputType_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
inputType_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -2337,7 +2337,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -2337,7 +2337,7 @@ namespace Google.Protobuf.Reflection {
public
string
OutputType
{
public
string
OutputType
{
get
{
return
outputType_
;
}
get
{
return
outputType_
;
}
set
{
set
{
outputType_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
outputType_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -2583,7 +2583,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -2583,7 +2583,7 @@ namespace Google.Protobuf.Reflection {
public
string
JavaPackage
{
public
string
JavaPackage
{
get
{
return
javaPackage_
;
}
get
{
return
javaPackage_
;
}
set
{
set
{
javaPackage_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
javaPackage_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -2600,7 +2600,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -2600,7 +2600,7 @@ namespace Google.Protobuf.Reflection {
public
string
JavaOuterClassname
{
public
string
JavaOuterClassname
{
get
{
return
javaOuterClassname_
;
}
get
{
return
javaOuterClassname_
;
}
set
{
set
{
javaOuterClassname_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
javaOuterClassname_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -2687,7 +2687,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -2687,7 +2687,7 @@ namespace Google.Protobuf.Reflection {
public
string
GoPackage
{
public
string
GoPackage
{
get
{
return
goPackage_
;
}
get
{
return
goPackage_
;
}
set
{
set
{
goPackage_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
goPackage_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -2773,7 +2773,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -2773,7 +2773,7 @@ namespace Google.Protobuf.Reflection {
public
string
ObjcClassPrefix
{
public
string
ObjcClassPrefix
{
get
{
return
objcClassPrefix_
;
}
get
{
return
objcClassPrefix_
;
}
set
{
set
{
objcClassPrefix_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
objcClassPrefix_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -2786,7 +2786,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -2786,7 +2786,7 @@ namespace Google.Protobuf.Reflection {
public
string
CsharpNamespace
{
public
string
CsharpNamespace
{
get
{
return
csharpNamespace_
;
}
get
{
return
csharpNamespace_
;
}
set
{
set
{
csharpNamespace_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
csharpNamespace_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -4369,7 +4369,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -4369,7 +4369,7 @@ namespace Google.Protobuf.Reflection {
public
string
IdentifierValue
{
public
string
IdentifierValue
{
get
{
return
identifierValue_
;
}
get
{
return
identifierValue_
;
}
set
{
set
{
identifierValue_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
identifierValue_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -4409,7 +4409,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -4409,7 +4409,7 @@ namespace Google.Protobuf.Reflection {
public
pb
::
ByteString
StringValue
{
public
pb
::
ByteString
StringValue
{
get
{
return
stringValue_
;
}
get
{
return
stringValue_
;
}
set
{
set
{
stringValue_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
stringValue_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -4419,7 +4419,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -4419,7 +4419,7 @@ namespace Google.Protobuf.Reflection {
public
string
AggregateValue
{
public
string
AggregateValue
{
get
{
return
aggregateValue_
;
}
get
{
return
aggregateValue_
;
}
set
{
set
{
aggregateValue_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
aggregateValue_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -4621,7 +4621,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -4621,7 +4621,7 @@ namespace Google.Protobuf.Reflection {
public
string
NamePart_
{
public
string
NamePart_
{
get
{
return
namePart_
;
}
get
{
return
namePart_
;
}
set
{
set
{
namePart_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
namePart_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -5004,7 +5004,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -5004,7 +5004,7 @@ namespace Google.Protobuf.Reflection {
public
string
LeadingComments
{
public
string
LeadingComments
{
get
{
return
leadingComments_
;
}
get
{
return
leadingComments_
;
}
set
{
set
{
leadingComments_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
leadingComments_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
@@ -5014,7 +5014,7 @@ namespace Google.Protobuf.Reflection {
...
@@ -5014,7 +5014,7 @@ namespace Google.Protobuf.Reflection {
public
string
TrailingComments
{
public
string
TrailingComments
{
get
{
return
trailingComments_
;
}
get
{
return
trailingComments_
;
}
set
{
set
{
trailingComments_
=
pb
::
Preconditions
.
CheckNotNull
(
value
,
"value"
);
trailingComments_
=
pb
::
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
}
}
}
}
...
...
csharp/src/Google.Protobuf/Reflection/TypeRegistry.cs
View file @
7762f163
...
@@ -91,7 +91,7 @@ namespace Google.Protobuf.Reflection
...
@@ -91,7 +91,7 @@ namespace Google.Protobuf.Reflection
/// <returns>A type registry for the given files.</returns>
/// <returns>A type registry for the given files.</returns>
public
static
TypeRegistry
FromFiles
(
IEnumerable
<
FileDescriptor
>
fileDescriptors
)
public
static
TypeRegistry
FromFiles
(
IEnumerable
<
FileDescriptor
>
fileDescriptors
)
{
{
Preconditions
.
CheckNotNull
(
fileDescriptors
,
nameof
(
fileDescriptors
));
Pr
otoPr
econditions
.
CheckNotNull
(
fileDescriptors
,
nameof
(
fileDescriptors
));
var
builder
=
new
Builder
();
var
builder
=
new
Builder
();
foreach
(
var
file
in
fileDescriptors
)
foreach
(
var
file
in
fileDescriptors
)
{
{
...
@@ -128,7 +128,7 @@ namespace Google.Protobuf.Reflection
...
@@ -128,7 +128,7 @@ namespace Google.Protobuf.Reflection
/// <returns>A type registry for the given files.</returns>
/// <returns>A type registry for the given files.</returns>
public
static
TypeRegistry
FromMessages
(
IEnumerable
<
MessageDescriptor
>
messageDescriptors
)
public
static
TypeRegistry
FromMessages
(
IEnumerable
<
MessageDescriptor
>
messageDescriptors
)
{
{
Preconditions
.
CheckNotNull
(
messageDescriptors
,
nameof
(
messageDescriptors
));
Pr
otoPr
econditions
.
CheckNotNull
(
messageDescriptors
,
nameof
(
messageDescriptors
));
return
FromFiles
(
messageDescriptors
.
Select
(
md
=>
md
.
File
));
return
FromFiles
(
messageDescriptors
.
Select
(
md
=>
md
.
File
));
}
}
...
...
csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs
View file @
7762f163
...
@@ -72,7 +72,7 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -72,7 +72,7 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns>An Any message with the content and type URL of <paramref name="message"/>.</returns>
/// <returns>An Any message with the content and type URL of <paramref name="message"/>.</returns>
public
static
Any
Pack
(
IMessage
message
)
public
static
Any
Pack
(
IMessage
message
)
{
{
Preconditions
.
CheckNotNull
(
message
,
"message"
);
Pr
otoPr
econditions
.
CheckNotNull
(
message
,
"message"
);
return
new
Any
{
TypeUrl
=
GetTypeUrl
(
message
.
Descriptor
),
Value
=
message
.
ToByteString
()
};
return
new
Any
{
TypeUrl
=
GetTypeUrl
(
message
.
Descriptor
),
Value
=
message
.
ToByteString
()
};
}
}
}
}
...
...
csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs
View file @
7762f163
...
@@ -118,7 +118,7 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -118,7 +118,7 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns>The negated value of this duration.</returns>
/// <returns>The negated value of this duration.</returns>
public
static
Duration
operator
-(
Duration
value
)
public
static
Duration
operator
-(
Duration
value
)
{
{
Preconditions
.
CheckNotNull
(
value
,
"value"
);
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
checked
checked
{
{
return
Normalize
(-
value
.
Seconds
,
-
value
.
Nanos
);
return
Normalize
(-
value
.
Seconds
,
-
value
.
Nanos
);
...
@@ -133,8 +133,8 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -133,8 +133,8 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns></returns>
/// <returns></returns>
public
static
Duration
operator
+(
Duration
lhs
,
Duration
rhs
)
public
static
Duration
operator
+(
Duration
lhs
,
Duration
rhs
)
{
{
Preconditions
.
CheckNotNull
(
lhs
,
"lhs"
);
Pr
otoPr
econditions
.
CheckNotNull
(
lhs
,
"lhs"
);
Preconditions
.
CheckNotNull
(
rhs
,
"rhs"
);
Pr
otoPr
econditions
.
CheckNotNull
(
rhs
,
"rhs"
);
checked
checked
{
{
return
Normalize
(
lhs
.
Seconds
+
rhs
.
Seconds
,
lhs
.
Nanos
+
rhs
.
Nanos
);
return
Normalize
(
lhs
.
Seconds
+
rhs
.
Seconds
,
lhs
.
Nanos
+
rhs
.
Nanos
);
...
@@ -149,8 +149,8 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -149,8 +149,8 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns>The difference between the two specified durations.</returns>
/// <returns>The difference between the two specified durations.</returns>
public
static
Duration
operator
-(
Duration
lhs
,
Duration
rhs
)
public
static
Duration
operator
-(
Duration
lhs
,
Duration
rhs
)
{
{
Preconditions
.
CheckNotNull
(
lhs
,
"lhs"
);
Pr
otoPr
econditions
.
CheckNotNull
(
lhs
,
"lhs"
);
Preconditions
.
CheckNotNull
(
rhs
,
"rhs"
);
Pr
otoPr
econditions
.
CheckNotNull
(
rhs
,
"rhs"
);
checked
checked
{
{
return
Normalize
(
lhs
.
Seconds
-
rhs
.
Seconds
,
lhs
.
Nanos
-
rhs
.
Nanos
);
return
Normalize
(
lhs
.
Seconds
-
rhs
.
Seconds
,
lhs
.
Nanos
-
rhs
.
Nanos
);
...
...
csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs
View file @
7762f163
...
@@ -59,8 +59,8 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -59,8 +59,8 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns>The difference between the two specified timestamps.</returns>
/// <returns>The difference between the two specified timestamps.</returns>
public
static
Duration
operator
-(
Timestamp
lhs
,
Timestamp
rhs
)
public
static
Duration
operator
-(
Timestamp
lhs
,
Timestamp
rhs
)
{
{
Preconditions
.
CheckNotNull
(
lhs
,
"lhs"
);
Pr
otoPr
econditions
.
CheckNotNull
(
lhs
,
"lhs"
);
Preconditions
.
CheckNotNull
(
rhs
,
"rhs"
);
Pr
otoPr
econditions
.
CheckNotNull
(
rhs
,
"rhs"
);
checked
checked
{
{
return
Duration
.
Normalize
(
lhs
.
Seconds
-
rhs
.
Seconds
,
lhs
.
Nanos
-
rhs
.
Nanos
);
return
Duration
.
Normalize
(
lhs
.
Seconds
-
rhs
.
Seconds
,
lhs
.
Nanos
-
rhs
.
Nanos
);
...
@@ -75,8 +75,8 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -75,8 +75,8 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns>The result of adding the duration to the timestamp.</returns>
/// <returns>The result of adding the duration to the timestamp.</returns>
public
static
Timestamp
operator
+(
Timestamp
lhs
,
Duration
rhs
)
public
static
Timestamp
operator
+(
Timestamp
lhs
,
Duration
rhs
)
{
{
Preconditions
.
CheckNotNull
(
lhs
,
"lhs"
);
Pr
otoPr
econditions
.
CheckNotNull
(
lhs
,
"lhs"
);
Preconditions
.
CheckNotNull
(
rhs
,
"rhs"
);
Pr
otoPr
econditions
.
CheckNotNull
(
rhs
,
"rhs"
);
checked
checked
{
{
return
Normalize
(
lhs
.
Seconds
+
rhs
.
Seconds
,
lhs
.
Nanos
+
rhs
.
Nanos
);
return
Normalize
(
lhs
.
Seconds
+
rhs
.
Seconds
,
lhs
.
Nanos
+
rhs
.
Nanos
);
...
@@ -91,8 +91,8 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -91,8 +91,8 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns>The result of subtracting the duration from the timestamp.</returns>
/// <returns>The result of subtracting the duration from the timestamp.</returns>
public
static
Timestamp
operator
-(
Timestamp
lhs
,
Duration
rhs
)
public
static
Timestamp
operator
-(
Timestamp
lhs
,
Duration
rhs
)
{
{
Preconditions
.
CheckNotNull
(
lhs
,
"lhs"
);
Pr
otoPr
econditions
.
CheckNotNull
(
lhs
,
"lhs"
);
Preconditions
.
CheckNotNull
(
rhs
,
"rhs"
);
Pr
otoPr
econditions
.
CheckNotNull
(
rhs
,
"rhs"
);
checked
checked
{
{
return
Normalize
(
lhs
.
Seconds
-
rhs
.
Seconds
,
lhs
.
Nanos
-
rhs
.
Nanos
);
return
Normalize
(
lhs
.
Seconds
-
rhs
.
Seconds
,
lhs
.
Nanos
-
rhs
.
Nanos
);
...
...
csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs
View file @
7762f163
...
@@ -41,7 +41,7 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -41,7 +41,7 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns>A newly-created Value message with the given value.</returns>
/// <returns>A newly-created Value message with the given value.</returns>
public
static
Value
ForString
(
string
value
)
public
static
Value
ForString
(
string
value
)
{
{
Preconditions
.
CheckNotNull
(
value
,
"value"
);
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
return
new
Value
{
StringValue
=
value
};
return
new
Value
{
StringValue
=
value
};
}
}
...
@@ -81,7 +81,7 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -81,7 +81,7 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns>A newly-created Value message an initial list value.</returns>
/// <returns>A newly-created Value message an initial list value.</returns>
public
static
Value
ForList
(
params
Value
[]
values
)
public
static
Value
ForList
(
params
Value
[]
values
)
{
{
Preconditions
.
CheckNotNull
(
values
,
"values"
);
Pr
otoPr
econditions
.
CheckNotNull
(
values
,
"values"
);
return
new
Value
{
ListValue
=
new
ListValue
{
Values
=
{
values
}
}
};
return
new
Value
{
ListValue
=
new
ListValue
{
Values
=
{
values
}
}
};
}
}
...
@@ -92,7 +92,7 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -92,7 +92,7 @@ namespace Google.Protobuf.WellKnownTypes
/// <returns>A newly-created Value message an initial struct value.</returns>
/// <returns>A newly-created Value message an initial struct value.</returns>
public
static
Value
ForStruct
(
Struct
value
)
public
static
Value
ForStruct
(
Struct
value
)
{
{
Preconditions
.
CheckNotNull
(
value
,
"value"
);
Pr
otoPr
econditions
.
CheckNotNull
(
value
,
"value"
);
return
new
Value
{
StructValue
=
value
};
return
new
Value
{
StructValue
=
value
};
}
}
}
}
...
...
src/google/protobuf/compiler/csharp/csharp_primitive_field.cc
View file @
7762f163
...
@@ -83,7 +83,7 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) {
...
@@ -83,7 +83,7 @@ void PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) {
}
else
{
}
else
{
printer
->
Print
(
printer
->
Print
(
variables_
,
variables_
,
" $name$_ = pb::Preconditions.CheckNotNull(value,
\"
value
\"
);
\n
"
);
" $name$_ = pb::Pr
otoPr
econditions.CheckNotNull(value,
\"
value
\"
);
\n
"
);
}
}
printer
->
Print
(
printer
->
Print
(
" }
\n
"
" }
\n
"
...
@@ -186,7 +186,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) {
...
@@ -186,7 +186,7 @@ void PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) {
}
else
{
}
else
{
printer
->
Print
(
printer
->
Print
(
variables_
,
variables_
,
" $oneof_name$_ = pb::Preconditions.CheckNotNull(value,
\"
value
\"
);
\n
"
);
" $oneof_name$_ = pb::Pr
otoPr
econditions.CheckNotNull(value,
\"
value
\"
);
\n
"
);
}
}
printer
->
Print
(
printer
->
Print
(
variables_
,
variables_
,
...
...
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