Skip to content

Enable nullable referenrce types in MICore#1595

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

Enable nullable referenrce types in MICore#1595
gregg-miskelly wants to merge 1 commit into
microsoft:mainfrom
gregg-miskelly:NullableRef_MICore

Conversation

@gregg-miskelly

Copy link
Copy Markdown
Member

No description provided.

@gregg-miskelly gregg-miskelly requested a review from Copilot June 22, 2026 22:36
@gregg-miskelly gregg-miskelly changed the title Nullablitiy for MICore Enable nullable referenrce types in MICore Jun 22, 2026

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 nullable reference types (NRT) in the MICore layer of MIEngine and updates MICore code to compile cleanly under #nullable enable, primarily by annotating reference types, tightening null-handling, and consolidating helpers/usings.

Changes:

  • Enable NRT in MICore.csproj and add shared nullable attributes support.
  • Update MICore APIs/implementations with ?, null!, and improved null checks (including use of NullableHelpers string helpers).
  • Introduce GlobalUsings.cs to centralize common imports/aliases used across MICore.

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/MICore/Utilities.cs Annotates optional identifier and uses nullability-aware string helper.
src/MICore/UnixUtilities.cs Annotates nullable parameters/locals and updates whitespace/empty checks.
src/MICore/Transports/UnixShellPortTransport.cs Initializes non-null fields with null!, updates nullable parameters and output handling.
src/MICore/Transports/TcpTransport.cs Makes _client nullable, updates certificate callback nullability, and null-safe disposal.
src/MICore/Transports/StreamTransport.cs Adds NRT annotations to core transport fields/methods and null-safe writer disposal/reads.
src/MICore/Transports/ServerTransport.cs Makes patterns/prefix nullable and hardens GetDirectoryName usage.
src/MICore/Transports/RunInTerminalTransport.cs Annotates nullable streams/tasks and tightens path/env handling for NRT.
src/MICore/Transports/PipeTransport.cs Annotates process/streams/strings and adjusts async stream reading to handle null lines.
src/MICore/Transports/MockTransport.cs NRT annotations for fields/reads and minor debug output formatting update.
src/MICore/Transports/LocalTransport.cs Hardens GetDirectoryName and environment variable handling under NRT.
src/MICore/Transports/ITransport.cs Updates interface signatures for nullable waitLoop, exitCode, and command outputs.
src/MICore/Transports/ClientServerTransport.cs Propagates nullable waitLoop and nullable command outputs.
src/MICore/RunInTerminalLauncher.cs Removes direct System.Diagnostics using (relies on centralized usings/aliases).
src/MICore/ProcessMonitor.cs Makes timer/event nullable-aware and updates callback signatures.
src/MICore/PlatformUtilities.cs Reworks diagnostics dependency via explicit type aliasing and NRT string checks.
src/MICore/MIResults.cs Adds NRT annotations and refactors parsing flow/error reporting for NRT.
src/MICore/MIException.cs Updates whitespace checks and makes cached message nullable.
src/MICore/MICore.csproj Enables <Nullable>enable</Nullable> and links shared nullable attributes file.
src/MICore/Logger.cs Makes host log channels nullable and adjusts logging helpers for NRT.
src/MICore/LaunchOptions.cs Broad NRT annotations and additional null checks in JSON/XML option parsing.
src/MICore/LaunchCommand.cs Annotates optional handlers/description and simplifies description fallback.
src/MICore/JsonLaunchOptions.cs Annotates many DTO properties and converter methods for nullable JSON values.
src/MICore/IncludeExcludeList.cs Initializes lazy fields eagerly and updates empty checks under NRT.
src/MICore/GlobalUsings.cs Adds global static import for nullable helpers and central aliasing.
src/MICore/ExceptionHelper.cs Ensures stack traces are non-null when logging under NRT.
src/MICore/DebuggerDisposedException.cs Annotates optional fields/parameters for disposal exception scenarios.
src/MICore/Debugger.cs Updates event nullability, null-handling, and other NRT-related refactors.
src/MICore/CommandLock.cs Annotates nullable fields and improves assert-based flow assumptions.
src/MICore/CommandFactories/MICommandFactory.cs NRT annotations across factory surface and parsing helpers.
src/MICore/CommandFactories/lldb.cs NRT updates and avoids returning null collections.
src/MICore/CommandFactories/gdb.cs NRT updates for lock token and line parsing.
src/MICore/Checksum.cs NRT updates for cached string and byte storage initialization.

Comment on lines +4 to +5
global using static global::Microsoft.DebugEngineHost.NullableHelpers;
global using Process = global::System.Diagnostics.Process;
Comment on lines 2233 to +2236
string serializerAssemblyPath = Path.Combine(thisModuleDir, thisModuleName + ".XmlSerializers.dll");
string thisModuleVersion = typeof(LaunchOptions).GetTypeInfo().Assembly.GetName().Version.ToString();
string thisModuleVersion = typeof(LaunchOptions).GetTypeInfo().Assembly.GetName().Version?.ToString() ?? string.Empty;
if (!File.Exists(serializerAssemblyPath))
return null;
return null!;
Comment on lines 2211 to 2214
// NOTE: You can look at MIEngine\src\MICore\obj\Debug\sgen\<random-temp-file-name>.cs to see the source code for this assembly.
Type serializerType = serializationAssembly.GetType("Microsoft.Xml.Serialization.GeneratedAssembly." + type.Name + "Serializer");
ConstructorInfo constructor = serializerType?.GetConstructor(new Type[0]);
Type? serializerType = serializationAssembly.GetType("Microsoft.Xml.Serialization.GeneratedAssembly." + type.Name + "Serializer");
ConstructorInfo? constructor = serializerType?.GetConstructor(new Type[0]);
if (constructor == null)
Comment thread src/MICore/MIResults.cs
Comment on lines +1158 to +1166
[DoesNotReturn]
private void ParseError(string message, Span input)
{
string result = CreateErrorMessageFromSpan(input);
Debug.Fail(message + ": " + result);

Logger?.WriteLine(LogLevel.Error, String.Format(CultureInfo.CurrentCulture, "MI parsing error: {0}: \"{1}\"", message, result));

throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, "MI parsing error: {0}: \"{1}\"", message, result));
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