Skip to content

Enable nullable reference types and resolve warnings #13

@JSv4

Description

@JSv4

Summary

The codebase currently has <Nullable>disable</Nullable> in the project file and suppresses CS8632 warnings. We should enable nullable reference types and properly annotate the codebase for improved null safety.

Current State

  • Docxodus.csproj has <Nullable>disable</Nullable>
  • CS8632 warnings are suppressed via <NoWarn>$(NoWarn);CS8073;CA2200;CS8632</NoWarn>
  • Some files already have nullable annotations (?) but without the nullable context enabled

Scope

Enabling nullable produces ~9,000 warnings across 61 source files. The most common issues:

Warning Description Count
CS8600 Converting possible null to non-nullable type ~3,100
CS8602 Dereference of possibly null reference ~2,300
CS8604 Possible null reference argument ~1,500
CS8618 Non-nullable field uninitialized in constructor ~600
CS8625 Cannot convert null literal to non-nullable type ~570
CS8603 Possible null reference return ~530

Recommended Approach

An incremental file-by-file approach is best:

  1. Add #nullable enable at the top of individual files
  2. Fix warnings in that file (add ? annotations, null checks, or ! where safe)
  3. Run tests to verify behavior unchanged
  4. Repeat for next file

Start with smaller, simpler files to build momentum.

Work Required

  1. Incrementally enable nullable per-file with #nullable enable
  2. Add appropriate nullable annotations to public APIs
  3. Fix or suppress nullable warnings in legacy code
  4. Once all files are done, enable <Nullable>enable</Nullable> in csproj
  5. Remove CS8632 from NoWarn

Files to Prioritize

Smaller utility files first, then tackle the larger ones:

  • PtOpenXmlUtil.cs - many nullable issues (large file)
  • WmlToHtmlConverter.cs - ImageInfo class fields
  • WmlComparer.cs - comparison unit classes

Labels

  • enhancement
  • tech-debt

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions