Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit dbb6f5b

Browse files
committed
Use null coalescing operator.
Signed-off-by: Konstantina Chremmou <[email protected]>
1 parent 8f830a7 commit dbb6f5b

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

csharp/gen_csharp_binding.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ and exposed_param p =
711711
and exposed_call_params message classname params =
712712
let exposedParams = List.map exposed_call_param params in
713713
let name = String.lowercase classname in
714-
let refParam = sprintf "(_%s != null) ? _%s : \"\"" name name in
714+
let refParam = sprintf "_%s ?? \"\"" name in
715715
let exposedParams = if is_method_static message then exposedParams else refParam::exposedParams in
716716
String.concat ", " ("session.uuid"::exposedParams)
717717

@@ -1270,8 +1270,8 @@ and convert_to_proxy thing ty = (*function*)
12701270
| Int -> sprintf "%s.ToString()" thing
12711271
| Bool
12721272
| Float -> thing
1273-
| Ref _ -> sprintf "(%s != null) ? %s : \"\"" thing thing
1274-
| String -> sprintf "(%s != null) ? %s : \"\"" thing thing
1273+
| Ref _ -> sprintf "%s ?? \"\"" thing
1274+
| String -> sprintf "%s ?? \"\"" thing
12751275
| Enum (name,_) -> sprintf "%s_helper.ToString(%s)" name thing
12761276
| Set (Ref name) -> sprintf "(%s != null) ? Helper.RefListToStringArray(%s) : new string[] {}" thing thing
12771277
| Set(String) -> thing

csharp/src/Session.cs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
/*
2-
* Copyright (c) Citrix Systems, Inc.
3-
* All rights reserved.
4-
*
5-
* Redistribution and use in source and binary forms, with or without
6-
* modification, are permitted provided that the following conditions
7-
* are met:
8-
*
9-
* 1) Redistributions of source code must retain the above copyright
10-
* notice, this list of conditions and the following disclaimer.
11-
*
12-
* 2) Redistributions in binary form must reproduce the above
13-
* copyright notice, this list of conditions and the following
14-
* disclaimer in the documentation and/or other materials
15-
* provided with the distribution.
16-
*
17-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20-
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21-
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22-
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24-
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25-
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26-
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27-
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
2+
* Copyright (c) Citrix Systems, Inc.
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions
7+
* are met:
8+
*
9+
* 1) Redistributions of source code must retain the above copyright
10+
* notice, this list of conditions and the following disclaimer.
11+
*
12+
* 2) Redistributions in binary form must reproduce the above
13+
* copyright notice, this list of conditions and the following
14+
* disclaimer in the documentation and/or other materials
15+
* provided with the distribution.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
20+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21+
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22+
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
2828
* OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

@@ -387,7 +387,7 @@ public string get_this_host()
387387

388388
public static string get_this_host(Session session, string _self)
389389
{
390-
return (string)session.proxy.session_get_this_host(session.uuid, (_self != null) ? _self : "").parse();
390+
return (string)session.proxy.session_get_this_host(session.uuid, _self ?? "").parse();
391391
}
392392

393393
public string get_this_user()
@@ -397,7 +397,7 @@ public string get_this_user()
397397

398398
public static string get_this_user(Session session, string _self)
399399
{
400-
return (string)session.proxy.session_get_this_user(session.uuid, (_self != null) ? _self : "").parse();
400+
return (string)session.proxy.session_get_this_user(session.uuid, _self ?? "").parse();
401401
}
402402

403403
public bool get_is_local_superuser()
@@ -407,12 +407,12 @@ public bool get_is_local_superuser()
407407

408408
public static bool get_is_local_superuser(Session session, string _self)
409409
{
410-
return session.proxy.session_get_is_local_superuser(session.uuid, (_self != null) ? _self : "").parse();
410+
return session.proxy.session_get_is_local_superuser(session.uuid, _self ?? "").parse();
411411
}
412412

413413
public static string[] get_rbac_permissions(Session session, string _self)
414414
{
415-
return session.proxy.session_get_rbac_permissions(session.uuid, (_self != null) ? _self : "").parse();
415+
return session.proxy.session_get_rbac_permissions(session.uuid, _self ?? "").parse();
416416
}
417417

418418
public DateTime get_last_active()
@@ -422,7 +422,7 @@ public DateTime get_last_active()
422422

423423
public static DateTime get_last_active(Session session, string _self)
424424
{
425-
return session.proxy.session_get_last_active(session.uuid, (_self != null) ? _self : "").parse();
425+
return session.proxy.session_get_last_active(session.uuid, _self ?? "").parse();
426426
}
427427

428428
public bool get_pool()
@@ -432,7 +432,7 @@ public bool get_pool()
432432

433433
public static bool get_pool(Session session, string _self)
434434
{
435-
return (bool)session.proxy.session_get_pool(session.uuid, (_self != null) ? _self : "").parse();
435+
return (bool)session.proxy.session_get_pool(session.uuid, _self ?? "").parse();
436436
}
437437

438438
public XenRef<Subject> get_subject()
@@ -442,7 +442,7 @@ public XenRef<Subject> get_subject()
442442

443443
public static XenRef<Subject> get_subject(Session session, string _self)
444444
{
445-
return new XenRef<Subject>(session.proxy.session_get_subject(session.uuid, (_self != null) ? _self : "").parse());
445+
return new XenRef<Subject>(session.proxy.session_get_subject(session.uuid, _self ?? "").parse());
446446
}
447447

448448
public string get_auth_user_sid()
@@ -452,7 +452,7 @@ public string get_auth_user_sid()
452452

453453
public static string get_auth_user_sid(Session session, string _self)
454454
{
455-
return (string)session.proxy.session_get_auth_user_sid(session.uuid, (_self != null) ? _self : "").parse();
455+
return (string)session.proxy.session_get_auth_user_sid(session.uuid, _self ?? "").parse();
456456
}
457457

458458
#region AD SID enumeration and bootout
@@ -508,7 +508,7 @@ public Dictionary<string, string> get_other_config()
508508

509509
public static Dictionary<string, string> get_other_config(Session session, string _self)
510510
{
511-
return Maps.convert_from_proxy_string_string(session.proxy.session_get_other_config(session.uuid, (_self != null) ? _self : "").parse());
511+
return Maps.convert_from_proxy_string_string(session.proxy.session_get_other_config(session.uuid, _self ?? "").parse());
512512
}
513513

514514
public void set_other_config(Dictionary<string, string> _other_config)
@@ -518,7 +518,7 @@ public void set_other_config(Dictionary<string, string> _other_config)
518518

519519
public static void set_other_config(Session session, string _self, Dictionary<string, string> _other_config)
520520
{
521-
session.proxy.session_set_other_config(session.uuid, (_self != null) ? _self : "", Maps.convert_to_proxy_string_string(_other_config)).parse();
521+
session.proxy.session_set_other_config(session.uuid, _self ?? "", Maps.convert_to_proxy_string_string(_other_config)).parse();
522522
}
523523

524524
public void add_to_other_config(string _key, string _value)
@@ -528,7 +528,7 @@ public void add_to_other_config(string _key, string _value)
528528

529529
public static void add_to_other_config(Session session, string _self, string _key, string _value)
530530
{
531-
session.proxy.session_add_to_other_config(session.uuid, (_self != null) ? _self : "", (_key != null) ? _key : "", (_value != null) ? _value : "").parse();
531+
session.proxy.session_add_to_other_config(session.uuid, _self ?? "", _key ?? "", _value ?? "").parse();
532532
}
533533

534534
public void remove_from_other_config(string _key)
@@ -538,7 +538,7 @@ public void remove_from_other_config(string _key)
538538

539539
public static void remove_from_other_config(Session session, string _self, string _key)
540540
{
541-
session.proxy.session_remove_from_other_config(session.uuid, (_self != null) ? _self : "", (_key != null) ? _key : "").parse();
541+
session.proxy.session_remove_from_other_config(session.uuid, _self ?? "", _key ?? "").parse();
542542
}
543543

544544
#endregion

0 commit comments

Comments
 (0)