From 924181e30d297a8d7c62126d5063481d257081b6 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Fri, 24 Jun 2022 18:59:45 +0200 Subject: [PATCH] bindings/c#: resolve lgtm warnings. --- .lgtm.yml | 3 ++- bindings/c#/run.me | 10 +++++----- bindings/c#/supranational.blst.cs | 14 +++++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.lgtm.yml b/.lgtm.yml index 134dcc7a..3e60e9c8 100644 --- a/.lgtm.yml +++ b/.lgtm.yml @@ -2,6 +2,8 @@ queries: - include: "*" - exclude: cpp/unused-static-function - exclude: cpp/include-non-header + - exclude: cs/call-to-unmanaged-code + - exclude: cs/unmanaged-code extraction: cpp: @@ -15,6 +17,5 @@ extraction: csharp: index: - buildless: true nuget_restore: false diff --git a/bindings/c#/run.me b/bindings/c#/run.me index ffc5ad19..b5bcff73 100755 --- a/bindings/c#/run.me +++ b/bindings/c#/run.me @@ -27,7 +27,7 @@ public enum ERROR { } public class Exception : ApplicationException { - private ERROR code; + private readonly ERROR code; public Exception(ERROR err) { code = err; } public override string Message @@ -265,7 +265,7 @@ static extern ERROR blst_core_verify_pk_in_g2([In] long[] pk, [In] long[] sig, [In] byte[] aug, size_t aug_len); public struct P1_Affine { - internal long[] point; + internal readonly long[] point; private static readonly int sz = (int)blst_p1_affine_sizeof()/sizeof(long); @@ -380,7 +380,7 @@ public struct P1 { private P1(bool _) { point = new long[sz]; } private P1(P1 p) { point = (long[])p.point.Clone(); } private long[] self() - { if (point==null) point = new long[sz]; return point; } + { if (point==null) { point = new long[sz]; } return point; } public P1(SecretKey sk) : this(true) { blst_sk_to_pk_in_g1(point, sk.key); } @@ -522,7 +522,7 @@ static extern bool blst_fp12_in_group([In] long[] a); static extern void blst_bendian_from_fp12([Out] byte[] ret, [In] long[] a); public struct PT { - internal long[] fp12; + internal readonly long[] fp12; private static readonly int sz = (int)blst_fp12_sizeof()/sizeof(long); @@ -590,7 +590,7 @@ void blst_pairing_raw_aggregate([In, Out] long[] ctx, [In] long[] q, static extern IntPtr blst_pairing_as_fp12([In] long[] ctx); public struct Pairing { - private long[] ctx; + private readonly long[] ctx; private static readonly int sz = (int)blst_pairing_sizeof()/sizeof(long); diff --git a/bindings/c#/supranational.blst.cs b/bindings/c#/supranational.blst.cs index c2a60810..21d797b2 100644 --- a/bindings/c#/supranational.blst.cs +++ b/bindings/c#/supranational.blst.cs @@ -26,7 +26,7 @@ public enum ERROR { } public class Exception : ApplicationException { - private ERROR code; + private readonly ERROR code; public Exception(ERROR err) { code = err; } public override string Message @@ -264,7 +264,7 @@ static extern ERROR blst_core_verify_pk_in_g2([In] long[] pk, [In] long[] sig, [In] byte[] aug, size_t aug_len); public struct P1_Affine { - internal long[] point; + internal readonly long[] point; private static readonly int sz = (int)blst_p1_affine_sizeof()/sizeof(long); @@ -379,7 +379,7 @@ public struct P1 { private P1(bool _) { point = new long[sz]; } private P1(P1 p) { point = (long[])p.point.Clone(); } private long[] self() - { if (point==null) point = new long[sz]; return point; } + { if (point==null) { point = new long[sz]; } return point; } public P1(SecretKey sk) : this(true) { blst_sk_to_pk_in_g1(point, sk.key); } @@ -527,7 +527,7 @@ static extern ERROR blst_core_verify_pk_in_g1([In] long[] pk, [In] long[] sig, [In] byte[] aug, size_t aug_len); public struct P2_Affine { - internal long[] point; + internal readonly long[] point; private static readonly int sz = (int)blst_p2_affine_sizeof()/sizeof(long); @@ -642,7 +642,7 @@ public struct P2 { private P2(bool _) { point = new long[sz]; } private P2(P2 p) { point = (long[])p.point.Clone(); } private long[] self() - { if (point==null) point = new long[sz]; return point; } + { if (point==null) { point = new long[sz]; } return point; } public P2(SecretKey sk) : this(true) { blst_sk_to_pk_in_g2(point, sk.key); } @@ -784,7 +784,7 @@ static extern void blst_fp12_mul([Out] long[] ret, [In] long[] a, static extern void blst_bendian_from_fp12([Out] byte[] ret, [In] long[] a); public struct PT { - internal long[] fp12; + internal readonly long[] fp12; private static readonly int sz = (int)blst_fp12_sizeof()/sizeof(long); @@ -852,7 +852,7 @@ void blst_pairing_raw_aggregate([In, Out] long[] ctx, [In] long[] q, static extern IntPtr blst_pairing_as_fp12([In] long[] ctx); public struct Pairing { - private long[] ctx; + private readonly long[] ctx; private static readonly int sz = (int)blst_pairing_sizeof()/sizeof(long);