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
dc0aeaa9
Commit
dc0aeaa9
authored
Jun 28, 2016
by
detlevschwabe
Committed by
Jon Skeet
Jun 28, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding conditional compiler symbol to support .NET 3.5 (#1713)
* Adding condition compiler symbol to support .NET 3.5
parent
7b5648ca
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
36 additions
and
5 deletions
+36
-5
TypeExtensionsTest.cs
.../Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs
+2
-1
PropertyInfoExtensions.cs
...c/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs
+8
-0
TypeExtensions.cs
csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs
+6
-0
JsonFormatter.cs
csharp/src/Google.Protobuf/JsonFormatter.cs
+11
-0
MessageDescriptor.cs
csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
+4
-0
FieldMaskPartial.cs
...rp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs
+5
-0
TimeExtensions.cs
csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs
+0
-4
No files found.
csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs
View file @
dc0aeaa9
...
@@ -67,7 +67,7 @@ namespace Google.Protobuf.Compatibility
...
@@ -67,7 +67,7 @@ namespace Google.Protobuf.Compatibility
{
{
Assert
.
AreEqual
(
expected
,
TypeExtensions
.
IsValueType
(
type
));
Assert
.
AreEqual
(
expected
,
TypeExtensions
.
IsValueType
(
type
));
}
}
#if !DOTNET35
[
Test
]
[
Test
]
[
TestCase
(
typeof
(
object
),
typeof
(
string
),
true
)]
[
TestCase
(
typeof
(
object
),
typeof
(
string
),
true
)]
[
TestCase
(
typeof
(
object
),
typeof
(
int
),
true
)]
[
TestCase
(
typeof
(
object
),
typeof
(
int
),
true
)]
...
@@ -129,5 +129,6 @@ namespace Google.Protobuf.Compatibility
...
@@ -129,5 +129,6 @@ namespace Google.Protobuf.Compatibility
{
{
Assert
.
Throws
<
AmbiguousMatchException
>(()
=>
TypeExtensions
.
GetMethod
(
type
,
name
));
Assert
.
Throws
<
AmbiguousMatchException
>(()
=>
TypeExtensions
.
GetMethod
(
type
,
name
));
}
}
#endif
}
}
}
}
csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs
View file @
dc0aeaa9
...
@@ -47,7 +47,11 @@ namespace Google.Protobuf.Compatibility
...
@@ -47,7 +47,11 @@ namespace Google.Protobuf.Compatibility
/// </summary>
/// </summary>
internal
static
MethodInfo
GetGetMethod
(
this
PropertyInfo
target
)
internal
static
MethodInfo
GetGetMethod
(
this
PropertyInfo
target
)
{
{
#if DOTNET35
var
method
=
target
.
GetGetMethod
();
#else
var
method
=
target
.
GetMethod
;
var
method
=
target
.
GetMethod
;
#endif
return
method
!=
null
&&
method
.
IsPublic
?
method
:
null
;
return
method
!=
null
&&
method
.
IsPublic
?
method
:
null
;
}
}
...
@@ -57,7 +61,11 @@ namespace Google.Protobuf.Compatibility
...
@@ -57,7 +61,11 @@ namespace Google.Protobuf.Compatibility
/// </summary>
/// </summary>
internal
static
MethodInfo
GetSetMethod
(
this
PropertyInfo
target
)
internal
static
MethodInfo
GetSetMethod
(
this
PropertyInfo
target
)
{
{
#if DOTNET35
var
method
=
target
.
GetSetMethod
();
#else
var
method
=
target
.
SetMethod
;
var
method
=
target
.
SetMethod
;
#endif
return
method
!=
null
&&
method
.
IsPublic
?
method
:
null
;
return
method
!=
null
&&
method
.
IsPublic
?
method
:
null
;
}
}
}
}
...
...
csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs
View file @
dc0aeaa9
...
@@ -49,6 +49,11 @@ namespace Google.Protobuf.Compatibility
...
@@ -49,6 +49,11 @@ namespace Google.Protobuf.Compatibility
/// Returns true if the target type is a value type, including a nullable value type or an enum, or false
/// Returns true if the target type is a value type, including a nullable value type or an enum, or false
/// if it's a reference type (class, delegate, interface - including System.ValueType and System.Enum).
/// if it's a reference type (class, delegate, interface - including System.ValueType and System.Enum).
/// </summary>
/// </summary>
#if DOTNET35
internal
static
bool
IsValueType
(
this
Type
target
)
{
return
target
.
IsValueType
;
}
#else
internal
static
bool
IsValueType
(
this
Type
target
)
internal
static
bool
IsValueType
(
this
Type
target
)
{
{
return
target
.
GetTypeInfo
().
IsValueType
;
return
target
.
GetTypeInfo
().
IsValueType
;
...
@@ -109,5 +114,6 @@ namespace Google.Protobuf.Compatibility
...
@@ -109,5 +114,6 @@ namespace Google.Protobuf.Compatibility
}
}
return
null
;
return
null
;
}
}
#endif
}
}
}
}
csharp/src/Google.Protobuf/JsonFormatter.cs
View file @
dc0aeaa9
...
@@ -885,6 +885,16 @@ namespace Google.Protobuf
...
@@ -885,6 +885,16 @@ namespace Google.Protobuf
return
originalName
;
return
originalName
;
}
}
#if DOTNET35
// TODO: Consider adding functionality to TypeExtensions to avoid this difference.
private
static
Dictionary
<
object
,
string
>
GetNameMapping
(
System
.
Type
enumType
)
=>
enumType
.
GetFields
(
BindingFlags
.
NonPublic
|
BindingFlags
.
Public
|
BindingFlags
.
Static
)
.
ToDictionary
(
f
=>
f
.
GetValue
(
null
),
f
=>
(
f
.
GetCustomAttributes
(
typeof
(
OriginalNameAttribute
),
false
)
.
FirstOrDefault
()
as
OriginalNameAttribute
)
// If the attribute hasn't been applied, fall back to the name of the field.
?.
Name
??
f
.
Name
);
#else
private
static
Dictionary
<
object
,
string
>
GetNameMapping
(
System
.
Type
enumType
)
=>
private
static
Dictionary
<
object
,
string
>
GetNameMapping
(
System
.
Type
enumType
)
=>
enumType
.
GetTypeInfo
().
DeclaredFields
enumType
.
GetTypeInfo
().
DeclaredFields
.
Where
(
f
=>
f
.
IsStatic
)
.
Where
(
f
=>
f
.
IsStatic
)
...
@@ -893,6 +903,7 @@ namespace Google.Protobuf
...
@@ -893,6 +903,7 @@ namespace Google.Protobuf
.
FirstOrDefault
()
.
FirstOrDefault
()
// If the attribute hasn't been applied, fall back to the name of the field.
// If the attribute hasn't been applied, fall back to the name of the field.
?.
Name
??
f
.
Name
);
?.
Name
??
f
.
Name
);
#endif
}
}
}
}
}
}
csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs
View file @
dc0aeaa9
...
@@ -34,6 +34,10 @@ using System;
...
@@ -34,6 +34,10 @@ using System;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Collections.ObjectModel
;
using
System.Linq
;
using
System.Linq
;
#if DOTNET35
// Needed for ReadOnlyDictionary, which does not exist in .NET 3.5
using
Google.Protobuf.Collections
;
#endif
namespace
Google.Protobuf.Reflection
namespace
Google.Protobuf.Reflection
{
{
...
...
csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs
View file @
dc0aeaa9
...
@@ -59,7 +59,12 @@ namespace Google.Protobuf.WellKnownTypes
...
@@ -59,7 +59,12 @@ namespace Google.Protobuf.WellKnownTypes
if
(
firstInvalid
==
null
)
if
(
firstInvalid
==
null
)
{
{
var
writer
=
new
StringWriter
();
var
writer
=
new
StringWriter
();
#if DOTNET35
var
query
=
paths
.
Select
(
JsonFormatter
.
ToCamelCase
);
JsonFormatter
.
WriteString
(
writer
,
string
.
Join
(
","
,
query
.
ToArray
()));
#else
JsonFormatter
.
WriteString
(
writer
,
string
.
Join
(
","
,
paths
.
Select
(
JsonFormatter
.
ToCamelCase
)));
JsonFormatter
.
WriteString
(
writer
,
string
.
Join
(
","
,
paths
.
Select
(
JsonFormatter
.
ToCamelCase
)));
#endif
return
writer
.
ToString
();
return
writer
.
ToString
();
}
}
else
else
...
...
csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs
View file @
dc0aeaa9
...
@@ -31,10 +31,6 @@
...
@@ -31,10 +31,6 @@
#endregion
#endregion
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Google.Protobuf.WellKnownTypes
namespace
Google.Protobuf.WellKnownTypes
{
{
...
...
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