From ce5ecc786e31a397a7276dbb93f63978b5aa82c2 Mon Sep 17 00:00:00 2001 From: Udayshankar Ravikumar Date: Mon, 4 Nov 2024 14:01:29 +0530 Subject: [PATCH] Code analysis. --- src/IEzrError.cs | 4 ++-- src/Runtime/Context.cs | 2 +- .../CompatWrappers/EzrSharpCompatibilityObjectInstance.cs | 3 +-- .../Executables/EzrSharpCompatibilityConstructor.cs | 2 +- .../Executables/EzrSharpCompatibilityExecutable.cs | 2 +- .../ObjectMembers/EzrSharpCompatibilityProperty.cs | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/IEzrError.cs b/src/IEzrError.cs index e77f10d..77c105d 100644 --- a/src/IEzrError.cs +++ b/src/IEzrError.cs @@ -1,5 +1,5 @@ -using System.Text; -using System; +using System; +using System.Text; namespace EzrSquared; diff --git a/src/Runtime/Context.cs b/src/Runtime/Context.cs index e99cff6..d3239a3 100644 --- a/src/Runtime/Context.cs +++ b/src/Runtime/Context.cs @@ -159,7 +159,7 @@ public Context(string name, bool isStatic, Position startPosition, Context? pare Id = UIDProvider.Get(); LinkedContexts = linkedContexts == 0 ? [] : new Context[linkedContexts]; - if (isStatic && StaticContext != null) + if (isStatic && StaticContext is not null) throw new ArgumentException("A context cannot be static AND have a static context assigned to it.", nameof(staticContext)); IsStatic = isStatic; diff --git a/src/Runtime/Types/CSharpWrappers/CompatWrappers/EzrSharpCompatibilityObjectInstance.cs b/src/Runtime/Types/CSharpWrappers/CompatWrappers/EzrSharpCompatibilityObjectInstance.cs index df82932..1e2bb26 100644 --- a/src/Runtime/Types/CSharpWrappers/CompatWrappers/EzrSharpCompatibilityObjectInstance.cs +++ b/src/Runtime/Types/CSharpWrappers/CompatWrappers/EzrSharpCompatibilityObjectInstance.cs @@ -1,7 +1,6 @@ using EzrSquared.Runtime.Types.CSharpWrappers.CompatWrappers.ObjectMembers; using EzrSquared.Runtime.Types.CSharpWrappers.CompatWrappers.ObjectMembers.Executables; using EzrSquared.Runtime.WrapperAttributes; -using EzrSquared.Util; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -39,7 +38,7 @@ public EzrSharpCompatibilityObjectInstance( | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)] Type instanceType, - + Context parentContext, Position startPosition, Position endPosition) : base(instanceType, instance, parentContext, startPosition, endPosition) { Tag = $"{Tag}.{SharpMemberName}.{SharpMember.GetHashCode()}"; diff --git a/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/Executables/EzrSharpCompatibilityConstructor.cs b/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/Executables/EzrSharpCompatibilityConstructor.cs index 5cb734d..e067a35 100644 --- a/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/Executables/EzrSharpCompatibilityConstructor.cs +++ b/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/Executables/EzrSharpCompatibilityConstructor.cs @@ -47,7 +47,7 @@ public EzrSharpCompatibilityConstructor( | DynamicallyAccessedMemberTypes.PublicFields | DynamicallyAccessedMemberTypes.NonPublicFields)] Type constructingType, - + ConstructorInfo sharpConstructor, Context parentContext, Position startPosition, Position endPosition, bool skipValidation = false) : base(sharpConstructor, null, parentContext, startPosition, endPosition, skipValidation) { ConstructingType = constructingType; diff --git a/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/Executables/EzrSharpCompatibilityExecutable.cs b/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/Executables/EzrSharpCompatibilityExecutable.cs index 4846b49..091e55c 100644 --- a/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/Executables/EzrSharpCompatibilityExecutable.cs +++ b/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/Executables/EzrSharpCompatibilityExecutable.cs @@ -43,7 +43,7 @@ public EzrSharpCompatibilityExecutable(TMethodBase sharpMethodBase, object? inst Tag = $"{Tag}.{SharpMemberName}.{UIDProvider.Get()}"; Parameters = SharpMember.GetParameters(); - + ParameterNames = Array.ConvertAll(Parameters, p => { string? definedName = p.GetCustomAttribute()?.Name; diff --git a/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/EzrSharpCompatibilityProperty.cs b/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/EzrSharpCompatibilityProperty.cs index e869f73..ea659a7 100644 --- a/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/EzrSharpCompatibilityProperty.cs +++ b/src/Runtime/Types/CSharpWrappers/CompatWrappers/ObjectMembers/EzrSharpCompatibilityProperty.cs @@ -47,7 +47,7 @@ public override void Execute(Reference[] arguments, Interpreter interpreter, Run if (arguments.Length == 0) { - if (AutoWrapperAttribute?.IsWriteOnly == true || SharpMember.GetMethod is null || (AutoWrapperAttribute == null && !SharpMember.GetMethod.IsPublic)) + if (AutoWrapperAttribute?.IsWriteOnly == true || SharpMember.GetMethod is null || (AutoWrapperAttribute is null && !SharpMember.GetMethod.IsPublic)) { result.Failure(new EzrIllegalOperationError($"Cannot get value from CSharp property wrapper \"{SharpMemberName}\" as it is write-only!", Context, StartPosition, EndPosition)); return; @@ -62,7 +62,7 @@ public override void Execute(Reference[] arguments, Interpreter interpreter, Run if (result.ShouldReturn) return; - if (AutoWrapperAttribute?.IsReadOnly == true || SharpMember.SetMethod is null || (AutoWrapperAttribute == null && !SharpMember.SetMethod.IsPublic)) + if (AutoWrapperAttribute?.IsReadOnly == true || SharpMember.SetMethod is null || (AutoWrapperAttribute is null && !SharpMember.SetMethod.IsPublic)) { result.Failure(new EzrIllegalOperationError($"Cannot set value to CSharp property wrapper \"{SharpMemberName}\" as it is read-only!", Context, StartPosition, EndPosition)); return;