Reputation: 21
Runtime environment: .net core 2.2 , same issue for .net framework 4.6.1
While trying to create gRPC bindings for C# for Google Assistant SDK, in EmbeddedAssistant.g.cs am getting compile time error "Cannot Convert from System.Type to Google.Type"
Project Available for Download
https://drive.google.com/file/d/1Pbmg0Zk-ozXHkWT6a6FMmBt79MTHn7_t/view?usp=sharing
i am also getting errors on Google.Protobuf that
"Type" is a namespace but is used like a type.
I followed instructions to integrate google assistant for C# (Other languages: gRPC)
Earlier it was throwing error that Google.Protobuf.Collections and Google.Protobuf.Reflection are not available, so i downloaded protobuf-csharp-3.9.0.zip from link at #2 , copied Google.Protobuf folder in my project folder, that error went way.
For Google.API and Google.Type Errors, i followed this Stackoverflow article and it was resolved.
Compiled Output where the error is :
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Api.AnnotationsReflection.Descriptor, global::Google.Type.LatlngReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AssistRequest), global::Google.Assistant.Embedded.V1Alpha2.AssistRequest.Parser, new[]{ "Config", "AudioIn" }, new[]{ "Type" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AssistResponse), global::Google.Assistant.Embedded.V1Alpha2.AssistResponse.Parser, new[]{ "EventType", "AudioOut", "ScreenOut", "DeviceAction", "SpeechResults", "DialogStateOut", "DebugInfo" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.AssistResponse.Types.EventType) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DebugInfo), global::Google.Assistant.Embedded.V1Alpha2.DebugInfo.Parser, new[]{ "AogAgentToAssistantJson" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AssistConfig), global::Google.Assistant.Embedded.V1Alpha2.AssistConfig.Parser, new[]{ "AudioInConfig", "TextQuery", "AudioOutConfig", "ScreenOutConfig", "DialogStateIn", "DeviceConfig", "DebugConfig" }, new[]{ "Type" }, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig), global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig.Parser, new[]{ "Encoding", "SampleRateHertz" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.AudioInConfig.Types.Encoding) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig), global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig.Parser, new[]{ "Encoding", "SampleRateHertz", "VolumePercentage" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.AudioOutConfig.Types.Encoding) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig), global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig.Parser, new[]{ "ScreenMode" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.ScreenOutConfig.Types.ScreenMode) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DialogStateIn), global::Google.Assistant.Embedded.V1Alpha2.DialogStateIn.Parser, new[]{ "ConversationState", "LanguageCode", "DeviceLocation", "IsNewConversation" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DeviceConfig), global::Google.Assistant.Embedded.V1Alpha2.DeviceConfig.Parser, new[]{ "DeviceId", "DeviceModelId" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.AudioOut), global::Google.Assistant.Embedded.V1Alpha2.AudioOut.Parser, new[]{ "AudioData" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.ScreenOut), global::Google.Assistant.Embedded.V1Alpha2.ScreenOut.Parser, new[]{ "Format", "Data" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.ScreenOut.Types.Format) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DeviceAction), global::Google.Assistant.Embedded.V1Alpha2.DeviceAction.Parser, new[]{ "DeviceRequestJson" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.SpeechRecognitionResult), global::Google.Assistant.Embedded.V1Alpha2.SpeechRecognitionResult.Parser, new[]{ "Transcript", "Stability" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut), global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut.Parser, new[]{ "SupplementalDisplayText", "ConversationState", "MicrophoneMode", "VolumePercentage" }, null, new[]{ typeof(global::Google.Assistant.Embedded.V1Alpha2.DialogStateOut.Types.MicrophoneMode) }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DebugConfig), global::Google.Assistant.Embedded.V1Alpha2.DebugConfig.Parser, new[]{ "ReturnDebugInfo" }, null, null, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Assistant.Embedded.V1Alpha2.DeviceLocation), global::Google.Assistant.Embedded.V1Alpha2.DeviceLocation.Parser, new[]{ "Coordinates" }, new[]{ "Type" }, null, null, null)
}));
}
Compiler Error on compiled output of EmbeddedAssistant.g.cs line 101 to 116
and Compiler error on Google.Protobuf ReflectionUtil.cs on Type Type is a namespace but used like a type.
internal static readonly Type[] EmptyTypes = new Type[0];
/// <summary>
/// Creates a delegate which will cast the argument to the type that declares the method,
/// call the method on it, then convert the result to object.
/// </summary>
/// <param name="method">The method to create a delegate for, which must be declared in an IMessage
/// implementation.</param>
internal static Func<IMessage, object> CreateFuncIMessageObject(MethodInfo method) =>
GetReflectionHelper(method.DeclaringType, method.ReturnType).CreateFuncIMessageObject(method);
Upvotes: 1
Views: 827
Reputation: 21
ISSUE RESOLVED
i used this link https://github.com/grpc/grpc/blob/master/src/csharp/BUILD-INTEGRATION.md
basically added minimum necessary .proto files from googleapis to make google assistant work. Image attached
Screenshot of what project looks like
then added Grpc , Grpc.Tools nuget package, followed instructions in above article to change .csproj and built it.
i just added following in my csproj
<Protobuf Include="**/*.proto" OutputDir="%(RelativePath)"/>
It generated the output shown in image
Build was failing but CS files were generated. Take the generated CS files , add them to your real project and add Google.Protobuf nuget package , build and you're good to go.
Upvotes: 1