restsharp / restsharp/RestSharp

After updating from version 111.2 to 111.3, a C++/CLI project that uses libraries that use Restsharp reports a C2870

Open
#2,233 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C#
Stars
9.8k
Forks
2.3k
PR merge metrics
No merged PRs in 30d

Description

We use a C++/CLI project as a bridge between a native C++ application (Embacadero C++ Builder) and a .Net 8 project (the C++/CLI library provides a C interface for the C++ application, which in turn is used to call partial functionality of project parts that have already been migrated to .Net).

This worked as long as our .Net libraries used at most version 111.2.0 of Restsharp. With the update to 111.3.0, the C++/CLI project throws several C2870 errors:

"C2870 'RestSharp': a namespace definition must appear either at file scope or immediately within another namespace definition <...>.nuget\packages\restsharp\111.3.0\lib\net8.0\RestSharp.dll"

Current workaround: RestSharp downgrade to 111.2

To Reproduce

  1. Create a new solution with a "C# Class Library" (I use .net 8), add Restsharp 111.3.0 per nuget as Dependency
  2. Add a new "CLR Class Library (.NET)"-Project, add the C#-Assembly as Dependency
  3. Build => C2870
  4. Downgrade the Restsharper-nuget to 111.2.0
  5. Build => Success

Expected behavior
The upgrade from 111.2.0 to 111.3.0 should not cause an error

Desktop (please complete the following information):

  • OS: Microsoft Windows 11 Pro (Build 10.0.22631)
  • .NET 8
  • RestSharp Version 111.2.0 and 111.3.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported reproduction: a .NET 8 C# Class Library using RestSharp 111.3.0 as a dependency and a CLR Class Library (.NET) project that references it. Compare the C++/CLI build with RestSharp 111.2.0 and 111.3.0, then verify that the C2870 errors no longer occur after the upgrade without relying on the downgrade workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.