Skip to content

Commit 48968cd

Browse files
committed
Fix some analyzer violations.
1 parent 0a1c3ec commit 48968cd

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

src/hosting/InjectedProgramContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private InjectedProgramContext(int? injectorProcessId, uint mainThreadId, nint m
3333

3434
[EditorBrowsable(EditorBrowsableState.Never)]
3535
[SuppressMessage("", "CA1031")]
36-
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
36+
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])]
3737
public static unsafe uint Initialize(void* parameter)
3838
{
3939
// Only meant to be called by the native module.

src/injection/AssemblyInjectorOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public sealed class AssemblyInjectorOptions
44
{
55
public string FileName { get; private set; } = null!;
66

7-
public ImmutableArray<string> Arguments { get; private set; } = ImmutableArray<string>.Empty;
7+
public ImmutableArray<string> Arguments { get; private set; } = [];
88

99
public string ModuleDirectory { get; private set; } = _defaultDirectory;
1010

src/injection/IO/ProcessMemoryStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,6 @@ public override ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationTo
173173

174174
public override void WriteByte(byte value)
175175
{
176-
Write(stackalloc[] { value });
176+
Write([value]);
177177
}
178178
}

src/memory/Code/FunctionHookGate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public GateFrame(FunctionHook hook, void** stackAddress)
117117
[ThreadStatic]
118118
private static GateContext? _context;
119119

120-
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
120+
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])]
121121
public static void* Enter(nint handle, void** rsp)
122122
{
123123
_context ??= new();
@@ -144,7 +144,7 @@ public GateFrame(FunctionHook hook, void** stackAddress)
144144
return hook.HookCode;
145145
}
146146

147-
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
147+
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvCdecl)])]
148148
public static void* Exit()
149149
{
150150
_context ??= new();

src/memory/Diagnostics/CallTrace.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,27 +206,27 @@ private static CallTrace CaptureCore(IEnumerable<CallFrameSymbolicator> symbolic
206206

207207
// Use RtlLookupFunctionEntry on 64-bit since it can pick up JIT'd code.
208208

209-
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
209+
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])]
210210
private static void* FunctionTableAccess32(HANDLE process, ulong address)
211211
{
212212
return SymFunctionTableAccess64(process, address);
213213
}
214214

215-
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
215+
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])]
216216
private static void* FunctionTableAccess64(HANDLE process, ulong address)
217217
{
218218
ulong unused;
219219

220220
return _rtlLookupFunctionEntry(address, &unused, null);
221221
}
222222

223-
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
223+
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])]
224224
private static ulong GetModuleBase32(HANDLE process, ulong address)
225225
{
226226
return SymGetModuleBase64(process, address);
227227
}
228228

229-
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
229+
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])]
230230
private static ulong GetModuleBase64(HANDLE process, ulong address)
231231
{
232232
ulong result;

src/samples/hooking/InjectedProgram.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ private static unsafe int TestHooking()
103103
}
104104
}
105105

106-
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
106+
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])]
107107
private static unsafe void FlushProcessWriteBuffersHook()
108108
{
109109
_counter++;

src/samples/trace/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public static int Main()
3333
}
3434

3535
[SuppressMessage("", "CA1031")]
36-
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvStdcall) })]
36+
[UnmanagedCallersOnly(CallConvs = [typeof(CallConvStdcall)])]
3737
private static int SetThreadDescriptionHook(nint hThread, char* lpThreadDescription)
3838
{
3939
try

src/system/ProcessObject.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static long ToTicks(FILETIME time)
109109
(nuint)length,
110110
VIRTUAL_ALLOCATION_TYPE.MEM_COMMIT | VIRTUAL_ALLOCATION_TYPE.MEM_RESERVE,
111111
(uint)(access == MemoryAccess.None ? PAGE_PROTECTION_FLAGS.PAGE_NOACCESS : (PAGE_PROTECTION_FLAGS)access),
112-
Span<MEM_EXTENDED_PARAMETER>.Empty) is var ptr and not null
112+
[]) is var ptr and not null
113113
? ptr
114114
: throw new Win32Exception();
115115
}

0 commit comments

Comments
 (0)