@@ -78,7 +78,7 @@ public override void Emit(RHC rhc, ObjExpr objx, CljILGen ilg)
7878
7979 Type retType ;
8080
81- if ( _method != null )
81+ if ( _method is not null )
8282 {
8383 EmitForMethod ( objx , ilg ) ;
8484 retType = _method . ReturnType ;
@@ -98,7 +98,7 @@ public override void EmitUnboxed(RHC rhc, ObjExpr objx, CljILGen ilg)
9898 {
9999 GenContext . EmitDebugInfo ( ilg , _spanMap ) ;
100100
101- if ( _method != null )
101+ if ( _method is not null )
102102 {
103103 EmitForMethod ( objx , ilg ) ;
104104 }
@@ -144,7 +144,7 @@ private void EmitForMethod(ObjExpr objx, CljILGen ilg)
144144 }
145145 public static readonly MethodInfo Method_MethodExpr_GetDelegate = typeof ( MethodExpr ) . GetMethod ( "GetDelegate" ) ;
146146
147- public static readonly Dictionary < int , Delegate > DelegatesMap = new ( ) ;
147+ public static readonly Dictionary < int , Delegate > DelegatesMap = [ ] ;
148148
149149 public static Delegate GetDelegate ( int key )
150150 {
@@ -178,7 +178,7 @@ private void EmitComplexCall(ObjExpr objx, CljILGen ilg)
178178 {
179179 i ++ ;
180180 Expr e = ha . ArgExpr ;
181- Type argType = e . HasClrType && e . ClrType != null && e . ClrType . IsPrimitive ? e . ClrType : typeof ( object ) ;
181+ Type argType = e . HasClrType && e . ClrType is not null && e . ClrType . IsPrimitive ? e . ClrType : typeof ( object ) ;
182182
183183 switch ( ha . ParamType )
184184 {
@@ -218,22 +218,27 @@ private void EmitComplexCall(ObjExpr objx, CljILGen ilg)
218218 // Unfortunately, the Expression.Dynamic method does not respect byRef parameters.
219219 // The workaround appears to be to roll your delegate type and then use Expression.MakeDynamic, as below.
220220
221- List < Type > callsiteParamTypes = new ( paramTypes . Count + 1 )
222- {
223- typeof ( System . Runtime . CompilerServices . CallSite )
224- } ;
225- callsiteParamTypes . AddRange ( paramTypes ) ;
221+ List < Type > callsiteParamTypes =
222+ [
223+ typeof ( System . Runtime . CompilerServices . CallSite ) , .. paramTypes
224+ ] ;
226225
227226 // PLAN9: Seeing if replacing this helps.
228227 //Type dynType = Microsoft.Scripting.Generation.Snippets.Shared.DefineDelegate("__interop__", returnType, callsiteParamTypes.ToArray());
229228 GenContext context = Compiler . CompilerContextVar . deref ( ) as GenContext ;
230- DynInitHelper dih = context ? . DynInitHelper ;
231- if ( dih is null )
232- throw new InvalidOperationException ( "Don't know how to handle callsite in this case" ) ;
233- Type dynType = dih . MakeDelegateType ( "__interop__" , callsiteParamTypes . ToArray ( ) , returnType ) ;
229+ DynInitHelper dih = ( context ? . DynInitHelper ) ?? throw new InvalidOperationException ( "Don't know how to handle callsite in this case" ) ;
230+ Type dynType = dih . MakeDelegateType ( "__interop__" , [ .. callsiteParamTypes ] , returnType ) ;
234231
235232 DynamicExpression dyn = Expression . MakeDynamic ( dynType , binder , paramExprs ) ;
236- EmitDynamicCallPreamble ( dyn , _spanMap , "__interop_" + _methodName + RT . nextID ( ) , returnType , paramExprs , paramTypes . ToArray ( ) , ilg , out Type delType , out MethodBuilder mbLambda ) ;
233+ EmitDynamicCallPreamble ( dyn ,
234+ _spanMap ,
235+ "__interop_" + _methodName + RT . nextID ( ) ,
236+ returnType ,
237+ paramExprs ,
238+ [ .. paramTypes ] ,
239+ ilg ,
240+ out _ ,
241+ out MethodBuilder mbLambda ) ;
237242
238243 // Emit target + args
239244
@@ -291,11 +296,11 @@ static FieldInfo GetCallSiteTarget(Type siteType)
291296 }
292297
293298
299+ #pragma warning disable IDE0060 // Remove unused parameter
294300 static public void EmitDynamicCallPreamble ( DynamicExpression dyn , IPersistentMap spanMap , string methodName , Type returnType , IList < ParameterExpression > paramExprs , Type [ ] paramTypes , CljILGen ilg , out Type delType , out MethodBuilder mbLambda )
301+ #pragma warning restore IDE0060 // Remove unused parameter
295302 {
296- GenContext context = Compiler . CompilerContextVar . deref ( ) as GenContext ;
297-
298- if ( context is null || context . DynInitHelper is null )
303+ if ( Compiler . CompilerContextVar . deref ( ) is not GenContext context || context . DynInitHelper is null )
299304 throw new InvalidOperationException ( "Don't know how to handle callsite in this case" ) ;
300305
301306 DynInitHelper . SiteInfo siteInfo = context . DynInitHelper . ComputeSiteInfo ( dyn ) ;
@@ -340,7 +345,6 @@ static public void EmitDynamicCallPreamble(DynamicExpression dyn, IPersistentMap
340345 ilg2 . Emit ( OpCodes . Ret ) ;
341346 }
342347
343- [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Style" , "IDE0060:Remove unused parameter" , Justification = "Standard API" ) ]
344348 static public void EmitDynamicCallPostlude ( MethodBuilder mbLambda , CljILGen ilg )
345349 {
346350 ilg . Emit ( OpCodes . Call , mbLambda ) ;
@@ -455,7 +459,7 @@ internal static void EmitConvertToType(CljILGen ilg, Type typeFrom, Type typeTo,
455459 // If the DLR folks had made this method public (instead of internal), I could call it directly.
456460 // Didn't feel like copying their code due to license/copyright.
457461
458- MI_EmitConvertToType . Invoke ( ilg , new Object [ ] { typeFrom , typeTo , isChecked } ) ;
462+ MI_EmitConvertToType . Invoke ( ilg , [ typeFrom , typeTo , isChecked ] ) ;
459463 }
460464
461465 #endregion
0 commit comments