Description
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