Skip to content

Enable nullable referenrce types in DebugEngineHost#1592

Draft
gregg-miskelly wants to merge 1 commit into
microsoft:mainfrom
gregg-miskelly:NullableRef_EngineHost
Draft

Enable nullable referenrce types in DebugEngineHost#1592
gregg-miskelly wants to merge 1 commit into
microsoft:mainfrom
gregg-miskelly:NullableRef_EngineHost

Conversation

@gregg-miskelly

Copy link
Copy Markdown
Member

This PR contains the work to enable nullable reference types for the first project in MIEngine -- the DebugEngineHost implementations.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables C# nullable reference types (NRT) across the DebugEngineHost implementations (VS, VSCode, and Stub contract), adding shims/attributes needed for older target frameworks and updating call sites to use nullable-aware patterns.

Changes:

  • Turn on <Nullable>enable</Nullable> for the DebugEngineHost projects and update APIs/fields to nullable annotations (?, is null, is not null, null-forgiving where needed).
  • Add shared compatibility code for NRT on older frameworks (NullableHelpers, NullableAttributes) and flow annotations (e.g., [MaybeNullWhen(false)]).
  • Set repo-wide C# language version to 12.0 and simplify shared source inclusion via *.cs globs + <Link>.

Reviewed changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Shared/NullableAttributes.cs Adds polyfill nullable/flow attributes for non-NETCOREAPP builds.
src/DebugEngineHost/VSImpl/VsWaitLoop.cs Makes message pump nullable and adds asserts for NRT flow.
src/DebugEngineHost/VSImpl/VsWaitDialog.cs Makes wait dialog nullable and updates null checks.
src/DebugEngineHost/VSImpl/VSEventCallbackWrapper.cs Makes cached callback nullable and updates checks.
src/DebugEngineHost/VSFeedbackLogger.cs Nullable-annotates watcher/writer and tightens null checks.
src/DebugEngineHost/RegistryMonitor.cs Nullable-annotates fields/events and adjusts event args / dispose.
src/DebugEngineHost/HostWaitLoop.cs Makes VS wait loop optional and uses null-conditional calls.
src/DebugEngineHost/HostWaitDialog.cs Makes underlying dialog optional and guards calls.
src/DebugEngineHost/HostTelemetry.cs Updates telemetry API to accept nullable engine name.
src/DebugEngineHost/HostRunInTerminal.cs Adds standard file header.
src/DebugEngineHost/HostOutputWindow.cs Nullable-annotates VS services returned from Lazy initializers.
src/DebugEngineHost/HostNatvisProject.cs Nullable-annotates option-watching APIs and VS services.
src/DebugEngineHost/HostMarshal.cs Removes unused using while moving toward NRT compliance.
src/DebugEngineHost/HostLogger.cs Nullable-annotates global channels/buffers and updates checks.
src/DebugEngineHost/HostLoader.cs Nullable-annotates COM type discovery/creation and registry reads.
src/DebugEngineHost/HostConfigurationStore.cs Nullable-annotates cached engine id and optional registry sections.
src/DebugEngineHost/HostConfigurationSection.cs Makes registry value retrieval return nullable object.
src/DebugEngineHost/Host.cs Removes unused using while moving toward NRT compliance.
src/DebugEngineHost/FeedbackDiagnosticFileProvider.cs Uses Process alias and removes unused using.
src/DebugEngineHost/DebugEngineHost.csproj Enables NRT and links shared sources (incl. nullable polyfills).
src/DebugEngineHost.VSCode/VSCode/HandleCollection.cs Adds flow annotations for out values and modernizes defaults.
src/DebugEngineHost.VSCode/VSCode/ExceptionSettings.cs Initializes required JSON fields for NRT.
src/DebugEngineHost.VSCode/VSCode/ExceptionBreakpointFilter.cs Initializes required JSON properties/fields for NRT.
src/DebugEngineHost.VSCode/VSCode/EngineConfiguration.cs Nullable-annotates statics/loads and adds deserialization null guard.
src/DebugEngineHost.VSCode/VSCode/AssemblyResolver.cs Nullable-annotates resolver return types and null checks.
src/DebugEngineHost.VSCode/HostTelemetry.cs Nullable-annotates state and hardens event payload strings.
src/DebugEngineHost.VSCode/HostRunInTerminal.cs Nullable-annotates callback and updates availability checks.
src/DebugEngineHost.VSCode/HostOutputWindow.cs Nullable-annotates callback and updates checks.
src/DebugEngineHost.VSCode/HostNatvisProject.cs Nullable-annotates return values for unsupported VSCode features.
src/DebugEngineHost.VSCode/HostMarshal.cs Updates dictionary lookups to use nullable out vars.
src/DebugEngineHost.VSCode/HostLogger.cs Nullable-annotates channels and file path; updates checks.
src/DebugEngineHost.VSCode/HostLoader.cs Updates signature to nullable return.
src/DebugEngineHost.VSCode/HostConfigurationStore.cs Hardens null handling for config lookup.
src/DebugEngineHost.VSCode/HostConfigurationSection.cs Makes value retrieval return nullable object.
src/DebugEngineHost.VSCode/DebugEngineHost.VSCode.csproj Enables NRT and links shared sources (incl. nullable polyfills).
src/DebugEngineHost.Stub/Shared/NullableHelpers.cs Adds NRT helper shims and Debug wrapper to improve flow analysis.
src/DebugEngineHost.Stub/DebugEngineHost.Stub.csproj Enables NRT and links nullable attribute polyfills.
src/DebugEngineHost.Stub/DebugEngineHost.ref.cs Updates public contract surface to nullable annotations.
src/DebugEngineHost.Common/HostLogChannel.cs Nullable-annotates file writer and adjusts optional log-file handling.
build/all_projects.settings.targets Sets repo-wide C# LangVersion to 12.0.
Comments suppressed due to low confidence (1)

src/DebugEngineHost/HostTelemetry.cs:63

  • engineName is now nullable, but in LAB builds it is passed through to ReportCurrentNonFatalException without a null guard. Since there are call sites that pass null, this can surface as an ArgumentNullException / telemetry failure in LAB. Also update the XML doc to reflect that this parameter is optional.

Comment thread src/Shared/NullableAttributes.cs
Comment on lines 125 to 129
_nativsLogger?.WriteLine(LogLevel.Error, Resource.Error_WatchRegistry, errorCode);
break;
}
RegChanged?.Invoke(this, null);
RegChanged?.Invoke(this, EventArgs.Empty);
}
Comment thread src/DebugEngineHost/RegistryMonitor.cs
Comment thread src/DebugEngineHost.Stub/Shared/NullableHelpers.cs
Comment thread src/DebugEngineHost.Stub/Shared/NullableHelpers.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants