发布

  • fix(raw): drop reflection in TryReadViaSdkPackage; use SDK public Experimental API

    frostbyte_neo 发布于 2026-05-09 12:20:43 +00:00 | 3400 次提交 在此版本后已推送到 main

    The 8297dfdf workaround used reflection (typeof(...).GetMethod /
    MakeGenericMethod / GetProperty) to reach the SDK's internal IPackage,
    because IPackageFeature is internal to DocumentFormat.OpenXml. This
    tripped trim analysis (IL2026 / IL2075 / IL2060 — 8 warnings on every
    publish since the reflection landed) and was fragile against any future
    SDK refactor that removes a static reference to those members.

    Turns out the SDK already exposes a public extension method:

    namespace DocumentFormat.OpenXml.Experimental;
    public static IPackage GetPackage(this OpenXmlPackage package);
    

    with public IPackage / IPackagePart interfaces. It is marked
    [Experimental("OOXML0001")], so suppress that single diagnostic at the
    using and call sites — the rest of the call chain (PartExists, GetPart,
    GetStream) is fully public.

    Effects:

    • Reflection block removed
    • 8 trim warnings gone (clean build)
    • No behavior change: resident editable .rels reads still work
    • Removed unused System.Reflection using
    下载附件