1111using CodeJam . Collections ;
1212using CodeJam . Expressions ;
1313
14+ using JetBrains . Annotations ;
15+
1416namespace CodeJam . Mapping
1517{
1618 using Reflection ;
1719
1820 internal static class ConvertBuilder
1921 {
22+ [ NotNull ]
2023 private static readonly MethodInfo _defaultConverter = InfoOf . Method ( ( ) => ConvertDefault ( null , typeof ( int ) ) ) ;
2124
22- private static object ConvertDefault ( object value , Type conversionType )
25+ private static object ConvertDefault ( object value , [ NotNull ] Type conversionType )
2326 {
2427 try
2528 {
@@ -31,7 +34,8 @@ private static object ConvertDefault(object value, Type conversionType)
3134 }
3235 }
3336
34- private static Expression GetCtor ( Type from , Type to , Expression p )
37+ [ CanBeNull ]
38+ private static Expression GetCtor ( [ NotNull ] Type from , [ NotNull ] Type to , [ NotNull ] Expression p )
3539 {
3640 var ctor = to . GetConstructor ( new [ ] { from } ) ;
3741
@@ -46,7 +50,8 @@ private static Expression GetCtor(Type from, Type to, Expression p)
4650 return Expression . New ( ctor , p ) ;
4751 }
4852
49- private static Expression GetValue ( Type from , Type to , Expression p )
53+ [ CanBeNull ]
54+ private static Expression GetValue ( [ NotNull ] Type from , [ NotNull ] Type to , [ NotNull ] Expression p )
5055 {
5156 var pi = from . GetProperty ( "Value" ) ;
5257
@@ -66,7 +71,7 @@ private static Expression GetValue(Type from, Type to, Expression p)
6671 private const BindingFlags _methodLookup =
6772 BindingFlags . Instance | BindingFlags . Static | BindingFlags . Public | BindingFlags . NonPublic ;
6873
69- private static Expression GetOperator ( Type from , Type to , Expression p )
74+ private static Expression GetOperator ( [ NotNull ] Type from , [ NotNull ] Type to , [ NotNull ] Expression p )
7075 {
7176 var op =
7277 to . GetMethod ( "op_Implicit" , _methodLookup , null , new [ ] { from } , null ) ??
@@ -75,7 +80,7 @@ private static Expression GetOperator(Type from, Type to, Expression p)
7580 return op != null ? Expression . Convert ( p , to , op ) : null ;
7681 }
7782
78- private static bool IsConvertible ( Type type )
83+ private static bool IsConvertible ( [ NotNull ] Type type )
7984 {
8085 if ( type . IsEnum )
8186 return false ;
@@ -99,7 +104,7 @@ private static bool IsConvertible(Type type)
99104 }
100105 }
101106
102- private static Expression GetConvertion ( Type from , Type to , Expression p )
107+ private static Expression GetConvertion ( [ NotNull ] Type from , [ NotNull ] Type to , [ NotNull ] Expression p )
103108 {
104109 if ( IsConvertible ( from ) && IsConvertible ( to ) && to != typeof ( bool ) ||
105110 from . IsAssignableFrom ( to ) && to . IsAssignableFrom ( from ) )
@@ -108,7 +113,7 @@ private static Expression GetConvertion(Type from, Type to, Expression p)
108113 return null ;
109114 }
110115
111- private static Expression GetParse ( Type from , Type to , Expression p )
116+ private static Expression GetParse ( [ NotNull ] Type from , [ NotNull ] Type to , [ NotNull ] Expression p )
112117 {
113118 if ( from == typeof ( string ) )
114119 {
@@ -133,7 +138,7 @@ private static Expression GetParse(Type from, Type to, Expression p)
133138 return null ;
134139 }
135140
136- private static Expression GetToString ( Type from , Type to , Expression p )
141+ private static Expression GetToString ( [ NotNull ] Type from , [ NotNull ] Type to , [ NotNull ] Expression p )
137142 {
138143 if ( to == typeof ( string ) && ! from . IsNullable ( ) )
139144 {
@@ -150,7 +155,7 @@ private static Expression GetToString(Type from, Type to, Expression p)
150155 return null ;
151156 }
152157
153- private static Expression GetParseEnum ( Type from , Type to , Expression p )
158+ private static Expression GetParseEnum ( [ NotNull ] Type from , [ NotNull ] Type to , [ NotNull ] Expression p )
154159 {
155160 if ( from == typeof ( string ) && to . IsEnum )
156161 {
@@ -210,7 +215,11 @@ into g
210215
211216 private static readonly MethodInfo _throwLinqToDBConvertException = InfoOf . Method ( ( ) => ThrowLinqToDBException ( null ) ) ;
212217
213- private static Expression GetToEnum ( Type from , Type to , Expression expression , MappingSchema mappingSchema )
218+ private static Expression GetToEnum (
219+ [ NotNull ] Type from ,
220+ [ NotNull ] Type to ,
221+ [ NotNull ] Expression expression ,
222+ [ NotNull ] MappingSchema mappingSchema )
214223 {
215224 if ( to . IsEnum )
216225 {
0 commit comments