microsoft / microsoft/OpenAPI.NET.OData

Microsoft.OData.Edm 9.0.0-rc compat: MissingMethodException on ExtensionMethods.GetReturn(IEdmOperation)

未关闭
#833 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
240
派生
70
平均合并
7 小时 59 分钟
30 天内合并 PR
13

描述

Summary

Microsoft.OpenApi.OData.Reader 3.2.1 throws System.MissingMethodException at runtime when used with Microsoft.OData.Edm 9.0.0-rc. The published 3.x assembly has IL that calls Microsoft.OData.Edm.ExtensionMethods.GetReturn(Microsoft.OData.Edm.IEdmOperation), but that extension method was removed in OData/odata.net@10c65053e and is therefore absent from the Microsoft.OData.Edm 9.0.0-rc NuGet package.

Affected versions
Package Version Status
Microsoft.OpenApi.OData 3.2.1 (latest 3.x) Calls GetReturn
Microsoft.OData.Edm 8.4.3 Has GetReturn — works
Microsoft.OData.Edm 9.0.0-preview.3 / preview.4 Missing GetReturn — breaks
Microsoft.OData.Edm 9.0.0-rc Missing GetReturn — breaks
Microsoft.OData.Edm main (post-9.0.0-rc) GetReturn restored in OData/odata.net@e375dd74e
Repro

Any model that produces at least one IEdmOperation path (entity sets are enough to make ODataPathProvider.RetrieveBoundOperationPaths walk the operation paths it accumulated and evaluate the _allOperationPaths.Where(...) lambda that calls GetReturn).

var model = builder.GetEdmModel();
var doc = model.ConvertToOpenApi(new OpenApiConvertSettings());
Exception
System.MissingMethodException: Method not found: 'Microsoft.OData.Edm.IEdmOperationReturn Microsoft.OData.Edm.ExtensionMethods.GetReturn(Microsoft.OData.Edm.IEdmOperation)'.
   at Microsoft.OpenApi.OData.Edm.ODataPathProvider.RetrieveBoundOperationPaths(OpenApiConvertSettings convertSettings)
   at Microsoft.OpenApi.OData.Edm.ODataPathProvider.GetPaths(IEdmModel model, OpenApiConvertSettings settings)
   at Microsoft.OpenApi.OData.Edm.ODataContext.LoadAllODataPaths()
   ...
   at Microsoft.OpenApi.OData.EdmModelOpenApiExtensions.ConvertToOpenApi(IEdmModel model, OpenApiConvertSettings settings)
Root cause

OData/odata.net PR 10c65053e ("Add 'ReturnType' default interface property into IEdmOperation, remove 'GetReturn' extension method", Nov 6, 2025) removed the static extension and added a ReturnType default interface member on IEdmOperation instead. The replacement is operation.Return (returns IEdmOperationReturn) — semantically equivalent, but a binary break for callers compiled against 8.x.

That removal shipped in 9.0.0-rc (May 5, 2026). The following day, OData/odata.net@e375dd74e brought GetReturn back as a back-compat extension on top of IEdmOperation.Return, so the next Edm 9.x release after 9.0.0-rc should restore source/binary compatibility with the existing OpenApi.OData 3.x release.

Disassembled callsites in Microsoft.OpenApi.OData.Reader.dll 3.2.1 (8 occurrences in total):

  • ODataPathProvider.RetrieveBoundOperationPaths (lambda over _allOperationPaths + body)
  • EdmOperationExtensions (operation-import path enumeration)
  • OperationHandler.AppendSystemQueryOptions(IEdmFunction)
  • EdmModelHelper.VisitOperation
  • … and a few more in schema-generation paths.
Ask
  1. Confirm 3.x will pick up the next Edm 9.x release (post-9.0.0-rc) once it ships with GetReturn restored.
  2. Plan a 4.x preview of Microsoft.OpenApi.OData that migrates the GetReturn(...) callsites to the new IEdmOperation.Return member, so consumers can target Edm 9.x without depending on the back-compat shim. Bumping the Microsoft.OData.Edm dependency from >= 8.4.3 to >= 9.x would also unblock consumers from forcibly overriding the floor (which is what surfaces this bug today).
Workaround

For consumers wedged against Edm 9.0.0-rc, the only options are (a) pin Microsoft.OData.Edm back to 8.x, or (b) wait for the next Edm 9.x release where GetReturn is restored.

Happy to PR step 2 if useful — let me know if there's an existing branch or design preference.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 model.ConvertToOpenApi repro 开始,检查 ODataPathProvider.RetrieveBoundOperationPaths、EdmOperationExtensions、OperationHandler.AppendSystemQueryOptions 和 EdmModelHelper.VisitOperation。跟踪报告的八处 GetReturn 调用点,并审查 Edm 9.x 的兼容性影响。完成标准是制定 4.x 迁移计划或完成使用 IEdmOperation.Return 的实现,并确认兼容性行为和依赖项版本变更。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp
领域
api, backend-api-design
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。