Refit creates RefitStubs.g.cs in PROJECT_NAME.RefitInternalGenerated namespace, so when project name contains characters which are not allowed to use in namespaces build fails.
1>obj\Debug\netcoreapp2.2\RefitStubs.g.cs(13,26,13,48): error CS0116: A namespace cannot directly contain members such as fields or methods
1>obj\Debug\netcoreapp2.2\RefitStubs.g.cs(13,22,13,25): error CS1514: { expected
1>obj\Debug\netcoreapp2.2\RefitStubs.g.cs(13,25,13,26): error CS1022: Type or namespace definition, or end-of-file expected
1>obj\Debug\netcoreapp2.2\RefitStubs.g.cs(14,1,14,2): error CS1022: Type or namespace definition, or end-of-file expected
1>Done building project "Playground App.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
C# language specification says that namespace name is an identifier, so all rules which are applicable to identifiers are also applicable to namespaces (namespace can't start from digit, etc.).
Project name rules are not to strict. My VS says that all valid NTFS directory names are allowed to use as project name.
So there are some limitations for project/solution names, it can't:
/ ? : & \ * " < > | # %CON, AUX, PRN, COM1 or LPT2. or ..Refit uses the $(RootNamespace) property (or $(RefitInternalNamespace) property if set in the project file) to add to the namespace of the PreserveAttribute.
I tested with a blank new .NET Standard class library and a .NET Core Console App, with spaces in the project names; and it doesn't give me any problems.
Could you provide a small sample that reproduces this?
Sure. Note that
When you create a blank project with spaces in name, VS will add sanitized namespace to <RootNamespace>, but when you rename existing project no additional info will be added to csproj.
@hankovich Thanks for the repro. I will look into it.
Closing due to age. Please try Refit v6 and reopen if still an issue.