Dreamescaper / GenerateAspNetCoreClient

DotNet tool to generate HTTP client classes from ASP.NET Core api controllers.
MIT License
63 stars 5 forks source link

.NET 6 support #5

Closed valentasm1 closed 2 years ago

valentasm1 commented 2 years ago

I think it stopped working on .net 6

C:\Dev\Dev\SuperCat\src\SuperCat\Controllers\UsersController.cs(303,37): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread. [C:\Dev\Dev\SuperCat\src\SuperCat\SuperCat.csproj]
Failed to find framework directory: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.Text.Json.JsonElement.GetProperty(String propertyName)
   at GenerateAspNetCoreClient.CustomLoadContext.GetFrameworkPath(String assemblyPath) in C:\Users\ollia\Source\Repos\GenerateAspNetCoreClient\GenerateAspNetCoreClient\CustomLoadContext.cs:line 87
Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at System.Reflection.RuntimeAssembly.InternalLoad(ObjectHandleOnStack assemblyName, ObjectHandleOnStack requestingAssembly, StackCrawlMarkHandle stackMark, Boolean throwOnFileNotFound, ObjectHandleOnStack assemblyLoadContext, ObjectHandleOnStack retAssembly)
   at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, RuntimeAssembly requestingAssembly, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, AssemblyLoadContext assemblyLoadContext)
   at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
   at GenerateAspNetCoreClient.CustomLoadContext.Load(AssemblyName assemblyName, Boolean fallbackToDefault) in C:\Users\ollia\Source\Repos\GenerateAspNetCoreClient\GenerateAspNetCoreClient\CustomLoadContext.cs:line 31
   at GenerateAspNetCoreClient.CustomLoadContext.Load(AssemblyName assemblyName) in C:\Users\ollia\Source\Repos\GenerateAspNetCoreClient\GenerateAspNetCoreClient\CustomLoadContext.cs:line 60
   at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
   at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
   at System.Reflection.RuntimeAssembly.get_EntryPoint()
   at GenerateAspNetCoreClient.Command.GenerateClientCommand.GetApiExplorer(Assembly assembly, String environment) in C:\Users\ollia\Source\Repos\GenerateAspNetCoreClient\GenerateAspNetCoreClient.Command\GenerateClientCommand.cs:line 42
   at GenerateAspNetCoreClient.Command.GenerateClientCommand.Invoke(Assembly assembly, GenerateClientOptions options) in C:\Users\ollia\Source\Repos\GenerateAspNetCoreClient\GenerateAspNetCoreClient.Command\GenerateClientCommand.cs:line 21
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at GenerateAspNetCoreClient.Program.CreateClient(GenerateClientOptions options) in C:\Users\ollia\Source\Repos\GenerateAspNetCoreClient\GenerateAspNetCoreClient\Program.cs:line 34
   at GenerateAspNetCoreClient.Program.<>c.<Main>b__0_0(GenerateClientOptions options) in C:\Users\ollia\Source\Repos\GenerateAspNetCoreClient\GenerateAspNetCoreClient\Program.cs:line 18
   at CommandLine.ParserResultExtensions.WithParsed[T](ParserResult`1 result, Action`1 action)
   at GenerateAspNetCoreClient.Program.Main(String[] args) in C:\Users\ollia\Source\Repos\GenerateAspNetCoreClient\GenerateAspNetCoreClient\Program.cs:line 16
Dreamescaper commented 2 years ago

Will take a look!

Dreamescaper commented 2 years ago

I have published updated version: https://www.nuget.org/packages/GenerateAspNetCoreClient.Refit/0.5.0

Please let me know if it works for you.

valentasm1 commented 2 years ago

It works now. Thank you very much.