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

Could not load System.Text.Json 7.0.0.0 #213

Open
2 tasks done
rametta opened this issue Dec 14, 2022 · 8 comments
Open
2 tasks done

Could not load System.Text.Json 7.0.0.0 #213

rametta opened this issue Dec 14, 2022 · 8 comments
Milestone

Comments

@rametta
Copy link

rametta commented Dec 14, 2022

Description

Hello, starting a new project and trying to use SwaggerProvider and following the getting started docs I get an error of:

The type provider 'SwaggerProvider.OpenApiClientTypeProvider' reported an error: Could not load file or assembly 'System.Text.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Could not find or load a specific file. (0x80131621)

when I try to init the first provider.

Repro steps

Start a new project, install SwaggerProvider 2.0.0-beta7. Follow the getting started docs, see error

Screen Shot 2022-12-14 at 10 47 46 AM

This happens with both SwaggerClientProvider and OpenApiClientProvider

here is my fsproj file

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>

        <IsPackable>false</IsPackable>
        <GenerateProgramFile>false</GenerateProgramFile>
    </PropertyGroup>

    <ItemGroup>
        <Compile Include="Tests.fs" />
        <Compile Include="Program.fs" />
    </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
        <PackageReference Include="SwaggerProvider" Version="2.0.0-beta7" />
        <PackageReference Include="xunit" Version="2.4.1" />
        <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
        <PackageReference Include="coverlet.collector" Version="3.1.0">
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
    </ItemGroup>

</Project>

Expected behavior

No error for missing dependencies

Actual behavior

Error showing that missing dependency and when explicitly installing that dependency the error still does not go away

Known workarounds

None that I know of, I can not get it to work.

Affected Type Providers

  • SwaggerClientProvider
  • OpenApiClientProvider

Related information

  • Operating system: MacOS Monterey
  • Branch
  • .NET Runtime, CoreCLR or Mono Version: Net6
  • Performance information, links to performance testing scripts
@sergey-tihon
Copy link
Member

Can you please try 2.0.0-beta6?

@rametta
Copy link
Author

rametta commented Dec 14, 2022

Yes that does seem to help, thank you

@rametta
Copy link
Author

rametta commented Dec 14, 2022

Although in Rider I keep getting error messages like this when trying to call an endpoint:

The type 'MyModule.MyProvider.Client' is not compatible with the type 'MyModule.MyProvider.Client'

Any ideas why there might be a type mismatch there?

@sergey-tihon
Copy link
Member

It is FSI/F# Interactive or compiled binary?

@rametta
Copy link
Author

rametta commented Dec 14, 2022

Compiled

@sergey-tihon sergey-tihon added this to the v2.0.0 milestone Dec 22, 2022
@Thorium
Copy link
Member

Thorium commented Mar 12, 2024

"The type X is not compatible with the type X" is typically that you defined type X in 2 different source-code paths, and A and B and then you make a function the takes A as parameter and you try to plug-in the type B when calling the function.

@sergey-tihon
Copy link
Member

Do you think that it is the caching issue of ProvidedTypes? https://github.com/fsprojects/SwaggerProvider/blob/master/src/SwaggerProvider.DesignTime/Caching.fs

@Thorium
Copy link
Member

Thorium commented Mar 12, 2024

I don't: As far as I know TypeProviders, I rather think (as a very wild guess, I've not seen this issue) that some source-file could be "included as a link" and thus defined both in design-time and runtime as a separate type. (The other option would be that it's loaded separately twice for different target frameworks which are actually compatible.) If that's the case, then the type should be probably defined in runtime only and referenced from runtime by the design-time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants