Skip to content

Commit

Permalink
Code analysis.
Browse files Browse the repository at this point in the history
  • Loading branch information
Uralstech committed Nov 4, 2024
1 parent c11981b commit ce5ecc7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/IEzrError.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Text;
using System;
using System;
using System.Text;

namespace EzrSquared;

Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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()}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<SharpAutoWrapperAttribute>()?.Name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit ce5ecc7

Please sign in to comment.