ch-robinson / dotnet-avro

An Avro implementation for .NET
https://engineering.chrobinson.com/dotnet-avro/
MIT License
135 stars 51 forks source link

The type could not be found. You may need to provide additional assemblies. #130

Closed alefcarlos closed 3 years ago

alefcarlos commented 3 years ago

Informations:

[Using WSL2]

dotnet avro --version
Chr.Avro.Cli 7.0.4
dotnet --list-sdks
3.1.302 [/usr/share/dotnet/sdk]

[Using Windows]

dotnet avro --version
Chr.Avro.Cli 7.0.4
dotnet --list-sdks
3.1.406 [C:\Program Files\dotnet\sdk]
5.0.103 [C:\Program Files\dotnet\sdk]

When I try to run the readme example: dotnet avro create -t System.Int32 I got this message: The type could not be found. You may need to provide additional assemblies.

How could I solve this ?

alefcarlos commented 3 years ago

The same thing happens when I try to create using my own assemblies.

dotnet avro create -a src/Super.GlobalPlatform.Authorizer.Events/bin/Debug/netstandard2.0/Super.GlobalPlatform.Authorizer.Events.dll -t Super.GlobalPlatform.Authorizer.Events.AuthorizationRequestApprovedEvent

image

I got this:

The type could not be found. You may need to provide additional assemblies.

dstelljes commented 3 years ago

Thanks for the detailed report. I think this might be the same thing as #127, although I’m not sure why it doesn’t work to generate a schema for your netstandard2.0 library (could be that if the build SDK is different, building schemas for mscorlib fails?). Will investigate further and tag as a blocker for 8.0.0.

alefcarlos commented 3 years ago

@dstelljes, I could generate using dotnet avro create -a System.Runtime -t System.Decimal, but without System.Runtime it doesnt work.

I tried this on Docker image as well and the same problem has ocorrued.

FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build

RUN dotnet tool install Chr.Avro.Cli --global

ENV PATH="/root/.dotnet/tools:${PATH}"

RUN dotnet avro create -t System.Int32
dstelljes commented 3 years ago

Interesting... does it work to generate a schema from your own assembly if you explicitly load System.Runtime as well?

dotnet avro create -a System.Runtime -a src/Super.GlobalPlatform.Authorizer.Events/bin/Debug/netstandard2.0/Super.GlobalPlatform.Authorizer.Events.dll -t Super.GlobalPlatform.Authorizer.Events.AuthorizationRequestApprovedEvent
alefcarlos commented 3 years ago

@dstelljes ,

dotnet avro create -a System.Runtime -a src/Super.GlobalPlatform.Authorizer.Events/bin/Debug/netstandard2.0/Super.GlobalPlatform.Authorizer.Events.dll -t Super.GlobalPlatform.Authorizer.Events.AuthorizationRequestApprovedEvent

Result:

Chr.Avro.Cli 7.0.4
Copyright (C) 2021 C.H. Robinson

ERROR(S):
  Option 'a, assembly' is defined multiple times.
USAGE:
Create a schema for a built-in type:
  dotnet avro create --type System.DateTime
Create a schema for a type in a compiled assembly:
  dotnet avro create --assembly ./out/Example.Models.dll --type Example.Models.ExampleModel
Create a schema for a type in a compiled assembly with dependencies:
  dotnet avro create --assembly System.Text.Json ./out/Example.Models.dll --type Example.Models.ExampleModel

  -a, --assembly           The name of or path to an assembly to load (multiple space-separated values accepted).

  --enums-as-integers      Whether enums should be represented with "int" or "long" schemas.

  --nullable-references    Whether reference types should be represented with nullable union schemas.

  --temporal-behavior      Whether timestamps should be represented with "string" schemas (ISO 8601) or "long" schemas     
                           (timestamp logical types). Options are iso8601, epochmilliseconds, and epochmicroseconds.       

  -t, --type               Required. The type to build a schema for.

  --help                   Display this help screen.

  --version                Display version information.
dstelljes commented 3 years ago

My bad, should have been

dotnet avro create -a System.Runtime src/Super.GlobalPlatform.Authorizer.Events/bin/Debug/netstandard2.0/Super.GlobalPlatform.Authorizer.Events.dll -t Super.GlobalPlatform.Authorizer.Events.AuthorizationRequestApprovedEvent
alefcarlos commented 3 years ago

Same error :(

The type could not be found. You may need to provide additional assemblies.
dstelljes commented 3 years ago

Shoot, thanks for checking. We should also improve that message; it’d be good to know which type specifically it was failing to find.

alefcarlos commented 3 years ago

hum... I got it, I need to pass all dependency assemblies as well, Im gonna try it.

davrobles commented 3 years ago

First, thank you for this very useful repo,

I'm having the same error, I've iterated the assembly classes and names are correct, when I try to generate It shows this:

The type could not be found. You may need to provide additional assemblies.

dotnet avro create --type AvroCsharpPOC.ExampleClass --assembly bin/Debug/net5.0/AvroCsharpPOC.dll

dstelljes commented 3 years ago

@davrobles, have you tried also passing System.Runtime as an assembly name as suggested above?

dotnet avro create --type AvroCsharpPOC.ExampleClass --assembly System.Runtime bin/Debug/net5.0/AvroCsharpPOC.dll
davrobles commented 3 years ago

@davrobles, have you tried also passing System.Runtime as an assembly name as suggested above?

dotnet avro create --type AvroCsharpPOC.ExampleClass --assembly System.Runtime bin/Debug/net5.0/AvroCsharpPOC.dll

It worked!

I had to change the target to .net core 3.1 and place the System.Runtime before the dll path, didn't work on .net 5 but I see you're already working on that.

Thank you so much @dstelljes

dstelljes commented 3 years ago

Thanks for your patience on this; the 7.1.0 release later today will add net5.0 as a CLI target framework and pull in System.Runtime by default.