File tree Expand file tree Collapse file tree 3 files changed +20
-32
lines changed Expand file tree Collapse file tree 3 files changed +20
-32
lines changed Original file line number Diff line number Diff line change 1+ using System . Collections ;
2+ using NHibernate . Util ;
3+ using NUnit . Framework ;
4+
5+ namespace NHibernate . Test . NHSpecificTest . NH3964
6+ {
7+ [ TestFixture ]
8+ public class Fixture
9+ {
10+ [ Test ( Description = "Test for removal of a workaround for an old Fx bug (<v4)" ) ]
11+ public void AddingNullToNonGenericListShouldNotThrow ( )
12+ {
13+ var a1 = new ArrayList { null } ;
14+ var a2 = new ArrayList ( ) ;
15+ Assert . DoesNotThrow ( ( ) => ArrayHelper . AddAll ( a2 , a1 ) ) ;
16+ }
17+ }
18+ }
Original file line number Diff line number Diff line change 737737 <Compile Include =" NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\Fixture.cs" />
738738 <Compile Include =" NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\FooExample.cs" />
739739 <Compile Include =" NHSpecificTest\EntityWithUserTypeCanHaveLinqGenerators\IExample.cs" />
740+ <Compile Include =" NHSpecificTest\NH3964\Fixture.cs" />
740741 <Compile Include =" NHSpecificTest\NH3950\Entity.cs" />
741742 <Compile Include =" NHSpecificTest\NH3950\Fixture.cs" />
742743 <Compile Include =" NHSpecificTest\NH3952\Entity.cs" />
Original file line number Diff line number Diff line change @@ -95,40 +95,9 @@ public static string ToString(object[] array)
9595 /// <param name="from"></param>
9696 public static void AddAll ( IList to , IList from )
9797 {
98- System . Action addNull = null ;
9998 foreach ( object obj in from )
10099 {
101- // There is bug in .NET, before version 4, where adding null to a List<Nullable<T>> through the non-generic IList interface throws an exception.
102- // TODO: Everything but the to.Add(obj) should be conditionally compiled only for versions of .NET earlier than 4.
103- if ( obj == null )
104- {
105- if ( addNull == null )
106- {
107- var toType = to . GetType ( ) ;
108- if ( toType . IsGenericType &&
109- toType . GetGenericTypeDefinition ( ) == typeof ( List < > ) &&
110- toType . GetGenericArguments ( ) [ 0 ] . IsNullable ( ) )
111- {
112- MethodInfo addMethod = toType . GetMethod ( "Add" ) ;
113- var addMethodCall = System . Linq . Expressions . Expression . Call ( System . Linq . Expressions . Expression . Constant ( to ) ,
114- addMethod ,
115- System . Linq . Expressions . Expression . Constant ( null , toType . GetGenericArguments ( ) [ 0 ] ) ) ;
116- System . Linq . Expressions . LambdaExpression addLambda =
117- System . Linq . Expressions . Expression . Lambda ( addMethodCall ) ;
118-
119- addNull = ( System . Action ) addLambda . Compile ( ) ;
120- }
121- else
122- {
123- addNull = ( ) => to . Add ( null ) ;
124- }
125- }
126- addNull ( ) ;
127- }
128- else
129- {
130- to . Add ( obj ) ;
131- }
100+ to . Add ( obj ) ;
132101 }
133102 }
134103
You can’t perform that action at this time.
0 commit comments