Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable nullable reference types by default #1237

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion Jint/AssemblyInfoExtras.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Runtime.CompilerServices;
using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Jint.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bf2553c9f214cb21f1f64ed62cadad8fe4f2fa11322a5dfa1d650743145c6085aba05b145b29867af656e0bb9bfd32f5d0deb1668263a38233e7e8e5bad1a3c6edd3f2ec6c512668b4aa797283101444628650949641b4f7cb16707efba542bb754afe87ce956f3a5d43f450d14364eb9571cbf213d1061852fb9dd47a6c05c4")]
[assembly: InternalsVisibleTo("Jint.Tests.Test262, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bf2553c9f214cb21f1f64ed62cadad8fe4f2fa11322a5dfa1d650743145c6085aba05b145b29867af656e0bb9bfd32f5d0deb1668263a38233e7e8e5bad1a3c6edd3f2ec6c512668b4aa797283101444628650949641b4f7cb16707efba542bb754afe87ce956f3a5d43f450d14364eb9571cbf213d1061852fb9dd47a6c05c4")]
Expand Down
4 changes: 3 additions & 1 deletion Jint/Collections/DictionarySlim.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
#nullable disable

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down
2 changes: 2 additions & 0 deletions Jint/Collections/HybridDictionary.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable disable

using System.Collections;
using System.Runtime.CompilerServices;

Expand Down
2 changes: 2 additions & 0 deletions Jint/Collections/ListDictionary.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#nullable disable

using System.Collections;
using System.Runtime.CompilerServices;
using Jint.Runtime;
Expand Down
2 changes: 1 addition & 1 deletion Jint/Collections/PropertyDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public PropertyDictionary(int capacity, bool checkExistingKeys) : base(capacity,
{
}
}
}
}
2 changes: 0 additions & 2 deletions Jint/Collections/RefStack.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#nullable enable

using System.Collections;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
Expand Down
4 changes: 3 additions & 1 deletion Jint/Collections/StringDictionarySlim.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Licensed to the .NET Foundation under one or more agreements.
#nullable disable

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down
2 changes: 1 addition & 1 deletion Jint/Collections/SymbolDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public SymbolDictionary(int capacity) : base(capacity)
{
}
}
}
}
2 changes: 1 addition & 1 deletion Jint/Constraints/CancellationConstraint.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Jint.Runtime;
using Jint.Runtime;
using System.Threading;

namespace Jint.Constraints
Expand Down
2 changes: 1 addition & 1 deletion Jint/Constraints/ConstraintsOptionsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Threading;
using System.Threading;
using Jint.Constraints;

namespace Jint
Expand Down
2 changes: 1 addition & 1 deletion Jint/Constraints/MaxStatements.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Jint.Runtime;
using Jint.Runtime;

namespace Jint.Constraints
{
Expand Down
4 changes: 2 additions & 2 deletions Jint/Constraints/MemoryLimit.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Jint.Runtime;
using Jint.Runtime;

namespace Jint.Constraints
{
internal sealed class MemoryLimit : IConstraint
{
private static readonly Func<long> GetAllocatedBytesForCurrentThread;
private static readonly Func<long>? GetAllocatedBytesForCurrentThread;
private readonly long _memoryLimit;
private long _initialMemoryUsage;

Expand Down
2 changes: 1 addition & 1 deletion Jint/Constraints/TimeConstraint.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Jint.Runtime;
using Jint.Runtime;

namespace Jint.Constraints
{
Expand Down
10 changes: 5 additions & 5 deletions Jint/Constraints/TimeConstraint2.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Jint.Runtime;
using Jint.Runtime;
using System.Threading;

namespace Jint.Constraints
{
internal sealed class TimeConstraint2 : IConstraint
{
private readonly TimeSpan _timeout;
private CancellationTokenSource cts;
private CancellationTokenSource? _cts;

public TimeConstraint2(TimeSpan timeout)
{
Expand All @@ -15,20 +15,20 @@ public TimeConstraint2(TimeSpan timeout)

public void Check()
{
if (cts.IsCancellationRequested)
if (_cts?.IsCancellationRequested == true)
{
ExceptionHelper.ThrowTimeoutException();
}
}

public void Reset()
{
cts?.Dispose();
_cts?.Dispose();

// This cancellation token source is very likely not disposed property, but it only allocates a timer, so not a big deal.
// But using the cancellation token source is faster because we do not have to check the current time for each statement,
// which means less system calls.
cts = new CancellationTokenSource(_timeout);
_cts = new CancellationTokenSource(_timeout);
}
}
}
2 changes: 1 addition & 1 deletion Jint/DeclarationBindingType.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Jint
namespace Jint
{
public enum DeclarationBindingType
{
Expand Down
10 changes: 4 additions & 6 deletions Jint/Engine.Modules.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#nullable enable

using Esprima;
using Esprima;
using Jint.Native;
using Jint.Native.Object;
using Jint.Native.Promise;
Expand All @@ -12,7 +10,7 @@ namespace Jint
{
public partial class Engine
{
internal IModuleLoader ModuleLoader { get; set; }
internal IModuleLoader ModuleLoader { get; set; } = null!;

private readonly Dictionary<string, ModuleRecord> _modules = new();
private readonly Dictionary<string, ModuleBuilder> _builders = new();
Expand Down Expand Up @@ -140,7 +138,7 @@ private JsValue EvaluateModule(string specifier, ModuleRecord cyclicModule)
{
if (ownsContext)
{
_activeEvaluationContext = null;
_activeEvaluationContext = null!;
}
}

Expand All @@ -151,7 +149,7 @@ private JsValue EvaluateModule(string specifier, ModuleRecord cyclicModule)
}
else if (promise.State == PromiseState.Rejected)
{
ExceptionHelper.ThrowJavaScriptException(this, promise.Value, new Completion(CompletionType.Throw, promise.Value, null, new Location(new Position(), new Position(), specifier)));
ExceptionHelper.ThrowJavaScriptException(this, promise.Value, new Completion(CompletionType.Throw, promise.Value!, null, new Location(new Position(), new Position(), specifier)));
}
else if (promise.State != PromiseState.Fulfilled)
{
Expand Down