forked from bUnit-dev/bUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBunitJSModuleInterop.cs
More file actions
47 lines (42 loc) · 1.44 KB
/
Copy pathBunitJSModuleInterop.cs
File metadata and controls
47 lines (42 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#if NET5_0_OR_GREATER
namespace Bunit;
/// <summary>
/// Represents a bUnit JSInterop module.
/// </summary>
public sealed class BunitJSModuleInterop : BunitJSInterop
{
private readonly BunitJSInterop parent;
private JSRuntimeMode? handlerMode;
/// <summary>
/// Gets or sets whether this <see cref="BunitJSInterop"/>
/// is running in <see cref="JSRuntimeMode.Loose"/> or <see cref="JSRuntimeMode.Strict"/>.
/// </summary>
/// <remarks>
/// When this is not set explicitly, the mode from <see cref="BunitJSInterop.Mode"/> is used.
/// As soon as this is set, the mode will no longer be changed when the <see cref="BunitJSInterop.Mode"/>
/// changes.
/// </remarks>
[SuppressMessage("Critical Bug", "S4275:Getters and setters should access the expected fields", Justification = "Analyzer bug. The property does correctly refer to the correct field(s).")]
public override JSRuntimeMode Mode
{
get => handlerMode ?? parent.Mode;
set => handlerMode = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="BunitJSModuleInterop"/> class.
/// </summary>
/// <param name="parent">The parent <see cref="BunitJSInterop"/>.</param>
public BunitJSModuleInterop(BunitJSInterop parent)
: base()
{
this.parent = parent;
handlerMode = null;
}
/// <inheritdoc/>
internal override void RegisterInvocation(JSRuntimeInvocation invocation)
{
Invocations.RegisterInvocation(invocation);
parent.RegisterInvocation(invocation);
}
}
#endif