Fakes Assembly generating error (Cannot implicitly convert type 'int' to 'bool') on AllInternalsVisible

Kyrylo Yavorenko 96 Reputation points
2021-10-11T17:09:57.247+00:00

Hello, I'm using VS 2019 Enterprise version 16.11.4 and I'm trying to generate fake assemblies from my own classes of that project or any other assembly (even 3rd party) I have the following errors:

  • project compilation failed with exit code 1;
  • Cannot implicitly convert type 'int' to 'bool'

And opening the error, it goes to the generated code and I can see that there is a following generated code:

// Some previous code

[assembly: global::System.Runtime.CompilerServices.InternalsVisibleTo("Primavera.Core.Applications, PublicKey=0024000004800000940000000602000000240000525341310004000001000100bfbbcfcfa45d349492d7a837b93e972950a9754029e1973b2f8cf38fabffba0b2380c15581b3a76d1626e4606f4c88ef2f03a0cc245e9390cd884545cf4021b6a177b6a0acef89d296adf0e2c631300b60bca05d38dcfb7318dbbcac767fd905dfdfcc05aea91a5aef718c4f9b5f2cc427671c6a4520f104f51da60f0c68e6c7", AllInternalsVisible = 1)]

// Some next code

And as you can see it tries to generate an int where it should be a bool:

AllInternalsVisible = 1

instead of

AllInternalsVisible = true

I'm using Microsoft.QualityTools.Testing.Fakes version 16.11.230815.

The test project where I'm adding fakes is .NET 5.0 and the assemblies that I'm generating fakes are .NET Standard 2.1

Can you help me fix this issue?

Developer technologies Visual Studio Testing
0 comments No comments
{count} votes

Accepted answer
  1. Kyrylo Yavorenko 96 Reputation points
    2021-11-09T12:07:48.697+00:00

    So the only workaround to do is removing the property since it's not implemented in .NET. With that, I can generate the fakes assemblies.

    More details here.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 31,056 Reputation points Microsoft External Staff
    2021-10-12T08:29:26.967+00:00

    Hi @Kyrylo Yavorenko ,

    Welcome to Microsoft Q&A!

    Can you create a new project to verify if the error occurs in all projects or not?

    Please try to delete the bin, obj and FakesAssemblies folders and recreate the Fakes assembly to check again.
    (Please backup the file before any modification, in case we need to roll back.)

    Meanwhile, you can also repair your Visual Studio in VS installer > More > Repair..

    Sincerely,
    Anna
    *
    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.