Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GenApi generate wrong interface when passing wrong --assembly-reference path #40639

Open
tarekgh opened this issue May 2, 2024 · 0 comments
Open
Assignees
Labels
Area-GenAPI untriaged Request triage from a team member

Comments

@tarekgh
Copy link
Member

tarekgh commented May 2, 2024

Describe the bug

When running the GenAPI tool to generate the interfaces from assembly and passing wrong path with the --assembly-reference option, it is possible to generate the readonly struct as sealed class. It generates some warnings for not finding some of the runtime assemblies, but it doesn't fail to generate the interfaces. Users can easily ignore the produced warnings as the tool already generated the interfaces.

To Reproduce

Run a command like:

genapi --assembly c:\oss\machinelearning\artifacts\bin\Microsoft.ML.Tokenizers\Release\net8.0\Microsoft.ML.Tokenizers.dll --assembly-reference "c:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.3\ref\net8.0" --assembly-reference c:\Users\ericstj\.nuget\packages\google.protobuf\3.24.3\lib\net5.0

The path c:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.3\ref\net8.0 is invalid not existing path. The assembly Microsoft.ML.Tokenizers.dll has public type defined as public readonly struct Token. The tool will produce the following warnings:

CP1002: Could not resolve reference 'System.Runtime.dll' in any of the provided search directories.
CP1002: Could not resolve reference 'System.Text.RegularExpressions.dll' in any of the provided search directories.
CP1002: Could not resolve reference 'Google.Protobuf.dll' in any of the provided search directories.
CP1002: Could not resolve reference 'System.Collections.dll' in any of the provided search directories.
CP1002: Could not resolve reference 'System.Text.Json.dll' in any of the provided search directories.
CP1002: Could not resolve reference 'System.Collections.Concurrent.dll' in any of the provided search directories.
CP1002: Could not resolve reference 'System.Net.Http.dll' in any of the provided search directories.
CP1002: Could not resolve reference 'System.Memory.dll' in any of the provided search directories.
CP1002: Could not resolve reference 'System.Linq.dll' in any of the provided search directories.
CP1002: Could not resolve reference 'System.Threading.dll' in any of the provided search directories.
CP1002: Could not resolve reference 'System.IO.Compression.dll' in any of the provided search directories.

But it will generated the type as public sealed partial class Token which is wrong.

It's advisable to refrain from generating any incorrect interfaces until the user resolves the --assembly-reference path. This prevents users from overlooking warnings and inadvertently utilizing incorrectly generated interfaces.
When fixing the --assembly-reference path, the tool work fine and generate the correct interfaces.

Exceptions (if any)

No exception

Further technical details

Microsoft.DotNet.GenAPI v9.0.100-preview.5.24227.1+0f7644da23265f1be382b28ff56f5505b0329334

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-NetSDK untriaged Request triage from a team member labels May 2, 2024
@baronfel baronfel removed their assignment May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-GenAPI untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

3 participants