You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,11 +146,15 @@ When working on the PowerShell module in VS Code:
146
146
-**Resource Management**: Use nested try/finally blocks for COM cleanup and resource management rather than flat structures with nullable checks, even if it results in deep indentation.
147
147
-**Null Checks**: When checking if a method returns a non-null value and using it, prefer pattern matching with `is` to tightly scope the variable: `if (Method() is Type variable) { ... }` instead of `var variable = Method(); if (variable != null) { ... }`. This scopes the variable to the branch where it's needed and makes the code more robust.
148
148
-**Inline Factory Method Usage**: When a factory method already provides context for what a value represents (e.g., `FromOrdinal()`), inline the expression directly rather than storing it in a temporary variable first. Example: prefer `entries.Add(DelayImportEntry.FromOrdinal((ushort)(thunkData & 0xFFFF)));` over creating a temporary `ushort ordinal = ...` variable.
149
+
-**Ternary Expression Formatting**: Favor the positive/valid scenario first. Example: `size >= HeaderSize ? new Instance(...) : null` instead of `size < HeaderSize ? null : new Instance(...)`. The only exception is when throwing - check for the invalid condition first, then throw.
149
150
-**ThrowIfNullOrWhiteSpace Usage**: When using the `ThrowIfNullOrWhiteSpace` extension method, do not pass explicit `nameof()` arguments — rely on the `[CallerMemberName]` attribute to automatically populate the name parameter.
150
151
-**SafeHandle Validation**: When validating SafeHandle parameters, avoid standalone `ThrowIfNullOrInvalid` or `ThrowIfNullOrClosed` calls that discard return values; inline the call into the subsequent usage (e.g., chain into `DangerousAddRef` or PInvoke argument).
151
152
-**RemoveFontResource Input**: Do not pre-validate `RemoveFontResource` input with file existence checks; it can operate on file names and not necessarily full paths.
152
153
-**Named Pipe Security**: Preserve strict named pipe security and reject solutions that weaken ACLs (e.g., creating pipes without explicit PipeSecurity).
153
154
155
+
### File Modification Guidelines
156
+
-**One Class Per File**: Each class should have its own dedicated file. Do not put multiple classes/records in a single file.
/// Defines the various CODEVIEW format signatures used for debugging information.
5
+
/// </summary>
6
+
/// <remarks>Each value corresponds to a specific version of the CODEVIEW format, which is essential for
7
+
/// interpreting debugging data correctly.</remarks>
8
+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design","CA1008:Enums should have zero value",Justification="These are signature values, not flags.")]
9
+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design","CA1028:Enum Storage should be Int32",Justification="The type is correct for the underlying Win32 API.")]
10
+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming","CA1707:Identifiers should not contain underscores",Justification="These values are precisely as they're defined in the Win32 API.")]
11
+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming","CA1712:Do not prefix enum values with type name",Justification="These are as they're defined within the API.")]
12
+
publicenumCODEVIEW_SIGNATURE:uint
13
+
{
14
+
/// <summary>
15
+
/// Represents the signature for the CODEVIEW format version NB09.
16
+
/// </summary>
17
+
CODEVIEW_SIGNATURE_NB09=0x3930424E,
18
+
19
+
/// <summary>
20
+
/// Represents the signature for the CODEVIEW format version NB10, which is associated with PDB 2.0 files.
21
+
/// </summary>
22
+
CODEVIEW_SIGNATURE_NB10=0x3031424E,
23
+
24
+
/// <summary>
25
+
/// Represents the signature for the CODEVIEW format version NB11.
26
+
/// </summary>
27
+
CODEVIEW_SIGNATURE_NB11=0x3131424E,
28
+
29
+
/// <summary>
30
+
/// Represents the signature for the RSDS code view format, used in debugging information.
/// Defines the set of signatures used to identify Profile-Guided Optimization (PGO) debug information within image
5
+
/// files. These signatures distinguish between various optimization techniques, such as Link-Time Code Generation
6
+
/// (LTCG), standard PGO, and sample-based PGO, enabling tools and compilers to interpret and process optimization
7
+
/// data appropriately.
8
+
/// </summary>
9
+
/// <remarks>This enumeration is intended for internal use when parsing or generating image files that
10
+
/// contain PGO-related debug information. Each value corresponds to a specific optimization strategy or data
11
+
/// format, which may affect how the debug information is handled during compilation or analysis. Refer to official
12
+
/// documentation or relevant image file specifications for details on the meaning and usage of each
13
+
/// signature.</remarks>
14
+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design","CA1008:Enums should have zero value",Justification="These are signature values, not flags.")]
15
+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design","CA1028:Enum Storage should be Int32",Justification="The type is correct for the underlying Win32 API.")]
16
+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming","CA1707:Identifiers should not contain underscores",Justification="These values are precisely as they're defined in the Win32 API.")]
17
+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming","CA1712:Do not prefix enum values with type name",Justification="These are as they're defined within the API.")]
18
+
publicenumIMAGE_DEBUG_POGO_SIGNATURE:uint
19
+
{
20
+
/// <summary>
21
+
/// Represents the signature for the POGO (Profile-Guided Optimization) debug information in the context of
0 commit comments