Enable nullable referenrce types in DebugEngineHost#1592
Draft
gregg-miskelly wants to merge 1 commit into
Draft
Conversation
There was a problem hiding this comment.
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
*.csglobs +<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
engineNameis now nullable, but inLABbuilds it is passed through toReportCurrentNonFatalExceptionwithout a null guard. Since there are call sites that pass null, this can surface as an ArgumentNullException / telemetry failure inLAB. Also update the XML doc to reflect that this parameter is optional.
Comment on lines
125
to
129
| _nativsLogger?.WriteLine(LogLevel.Error, Resource.Error_WatchRegistry, errorCode); | ||
| break; | ||
| } | ||
| RegChanged?.Invoke(this, null); | ||
| RegChanged?.Invoke(this, EventArgs.Empty); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains the work to enable nullable reference types for the first project in MIEngine -- the DebugEngineHost implementations.