Enable nullable referenrce types in MICore#1595
Draft
gregg-miskelly wants to merge 1 commit into
Draft
Conversation
There was a problem hiding this comment.
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.csprojand add shared nullable attributes support. - Update MICore APIs/implementations with
?,null!, and improved null checks (including use ofNullableHelpersstring helpers). - Introduce
GlobalUsings.csto 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 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)); |
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.
No description provided.