@@ -1308,10 +1308,13 @@ public static TryExpression TryFinally(Expression body, Expression @finally) =>
13081308 new WithFinallyTryExpression ( body , null , @finally ) ;
13091309
13101310 public static CatchBlock Catch ( ParameterExpression variable , Expression body ) =>
1311- new CatchBlock ( variable , body , null , variable . Type ) ;
1311+ new CatchBlock ( variable . Type , variable , body , null ) ;
13121312
13131313 public static CatchBlock Catch ( Type test , Expression body ) =>
1314- new CatchBlock ( null , body , null , test ) ;
1314+ new CatchBlock ( test , null , body , null ) ;
1315+
1316+ public static CatchBlock MakeCatchBlock ( Type test , ParameterExpression variable , Expression body , Expression filter ) =>
1317+ new CatchBlock ( test , variable , body , filter ) ;
13151318
13161319 /// <summary>Creates a UnaryExpression that represents a throwing of an exception.</summary>
13171320 public static UnaryExpression Throw ( Expression value ) => new ThrowUnaryExpression ( value ) ;
@@ -3247,19 +3250,18 @@ internal WithFinallyTryExpression(Expression body, CatchBlock[] handlers, Expres
32473250 Finally = @finally ;
32483251 }
32493252
3250- // todo: @perf convert to class and minimize the memory for the general cases
3251- public struct CatchBlock
3253+ public sealed class CatchBlock
32523254 {
3255+ public readonly Type Test ;
32533256 public readonly ParameterExpression Variable ;
32543257 public readonly Expression Body ;
32553258 public readonly Expression Filter ;
3256- public readonly Type Test ;
3257- internal CatchBlock ( ParameterExpression variable , Expression body , Expression filter , Type test )
3259+ internal CatchBlock ( Type test , ParameterExpression variable , Expression body , Expression filter )
32583260 {
3261+ Test = test ;
32593262 Variable = variable ;
3260- Body = body ;
3261- Filter = filter ;
3262- Test = test ;
3263+ Body = body ;
3264+ Filter = filter ;
32633265 }
32643266 }
32653267
0 commit comments