1

I've just updated a Xamarin solution using the refit package (2.3.0. -> 2.4.1) and now the build is complaining:

RefitStubs.g.cs(37,27): error CS0102: The type `Sample.App.Api' already contains a definition for `Client'
    RefitStubs.cs(37,27): (Location of the symbol related to previous error)

I've tried reverting the package version but same error occurs. I've cleaned the solution but still the same issue

amun1000
  • 453
  • 1
  • 8
  • 18

4 Answers4

1

I've had related problems from the *.g.cs generated files... I do not know why the file is not overwritten sometimes during a (Re)Build All, but in other's projects that I've seen, make sure that you do not have a reference to the generated file itself within your project (.csproj) which sometimes happens when you are debugging into the *.g.cs file.

Also Clean All does not remove the Refit build task generated file RefitStubs.g.cs (or RefitParams.rsp) from the obj directory.

Try deleting the obj directory and perform a (Re)Build All again to see if that helps.

After (Re)Build All:

obj/ > ls -1
RefitParams.rsp
RefitStubs.g.cs
refit-test.csproj.FilesWrittenAbsolute.txt
refit-test.exe
refit-test.exe.mdb

After Clean All:

obj/ > la -1
RefitParams.rsp
RefitStubs.g.cs
SushiHangover
  • 73,120
  • 10
  • 106
  • 165
1

Look if you have a refitStubs.cs file in your project root and remove it. Worked for me ;)

cristianomad
  • 303
  • 2
  • 9
0

Sorted by resorting back to the previous version of Refit

amun1000
  • 453
  • 1
  • 8
  • 18
0

Like @cristianomad stated, this occurs due to the fact that Refit moved from using RefitStubs.cs which is public -to- RefitStubs.g.cs which is located in the /obj folder, therefore generating the same classes in the two files.

Simply remove the old RefitStubs.cs file and you´d be good to go.

Ahmed Alejo
  • 2,334
  • 2
  • 16
  • 16