csproj tags Follow
There are a couple of tags in csproj that I think you don't handle properly. I'm not sure if this is documented anywhere (ie: by Microsoft) but the three tags TargetFramework, Platform, and Configuration all have optional plural forms. (There may be others that I don't know about.)
As far as I know from testing, the plural forms enable delimiters. The delimiters can be spaces, so for example <Platforms>Any CPU</Platforms> can cause problems since that will be interpreted as two platforms Any and CPU. (Quotes must be used in the plural form, but in the singular form, you cannot use quotes or they will be read as part of the name.)
The problem is that Rider doesn't seem to be aware of the two kinds of tag.
TargetFramework(s): it does seem to handle this one ok.
Platform(s): the intellisense is only aware of Platform and not Platforms, but if you use Platform, Rider will automatically add a duplicate Platforms tag. It also does not provide warnings with using Platforms with one platform, or Platform with many platforms.
Configuration(s): I think the same as Platform(s): the intellisense is only aware of Configuration and not Configurations, but will automatically add a duplicate Configurations tag, and it does not provide warnings about a Configurations tag with one configuration or a Configuration tag with many.
Please sign in to leave a comment.
This is a known issue: https://youtrack.jetbrains.com/issue/RIDER-26001. Please feel free to vote for it.
not sure that's the same. that is asking for more intellisense and auto-complete in csproj.
I am saying that there are bugs in how Rider handles some of the tags. If I add a <Platform> tag, Rider will still add its own <Platforms> tag, even though it does not list Platforms as an option. Rider has incomplete knowledge of both tags, causing them to collide. The part of Rider that scans the csproj doesn't know about <Platform>, and the intellisense part doesn't know about <Platforms>, resulting in constant duplicated tags. The workaround for now is to ignore the intellisense, and always use <Platforms>, even with only one platform, (which immediately leads to problems if you try to use <Platforms>Any CPU</Platforms> because Platforms treats the space as a delimiter and you get errors about there not being an "Any" platform, or a "CPU" platform (though note that those errors show up when using VS not Rider; not sure why.)).
This is not really a feature request, it's a bug fix.
I guess maybe you just generalize it to "improve csproj editing" or something.
It seems that I misunderstood your case.
Checked one more time and I cannot get the behaviour you describe. If I add, for example, a Platform tag, Rider adds it without any issues.
Maybe there are some special conditions for getting this behaviour. Could you share your csproj file here? Also, please clarify your Rider version.
Intellisense only knows about the existence of <Platform> and <Configuration>. But to specify, for example, Release;Debug should require use of the <Configurations> tag. And, at some point, Rider will insert <Platforms> or <Configurations> tags even if you already have <Platform> and <Configuration> tags. (I am assuming that Configuration/Configurations works the same as Platform/Platforms. Probably normally no one would ever use <Configuration>.)
(not 100% sure when new tags are added, could be package restore or Synching projects, or something like that)
(not 100% sure that it's Rider that adds them, but I think it is)
These tags are not well-documented by Microsoft, so I think the Rider devs don't quite understand how they work and may not even realize that they are in pairs.
There are a lot of subtle differences between how the tags are supposed to work and how Rider handles them. It's not easy to list every single one, and it requires a lot of testing.
The main obvious one is this:
If you try to add <Platforms>, intellisense doesn't know about it.
If you add <Platform>x86</Platform>, then later (on compile, package restore, sync projects, not sure which; or maybe it is when using configuration manager?) Rider will add a duplicate <Platforms>x86</Platforms> tag. This does not lead to an explicit error (though maybe it should), but now you have two copies of effectively the same tag.
The workaround is to always ignore intellisense and manually add <Platforms>x86</Platforms>
Ideally I should be able to add <Platform> via intellisense, and *not* later get a duplicate <Platforms> tag.
Ideally <Platforms>x86</Platforms> should generate a warning that I am using a single platform with the plural tag.
Ideally I should be able to add <Configurations> via intellisense as well, and not just <Configuration>.
Additionally, duplicate Platform/Platforms tags should maybe be a warning or error (maybe that is up to msbuild though)
The tag <Platforms>Any CPU</Platforms> should cause an error (at least it does on VS) but for some reason does not in Rider. (Maybe it depends on MSBuild version?) (The reason this should be an error is that <Platforms> interprets the space as a delimiter, and is supposed to read that as saying two platforms: Any, and CPU, neither of which exist. The correct tag would be <Platforms>"Any CPU"</Platforms> but that should be suggested to be <Platform>Any CPU</Platform>.)
My Rider version is 2021.1.5
Thank you very much for such a detailed description.
I've filed two issues for better analysis and completion of those tags.
Unfortunately, I was not able to reproduce this behaviour. Maybe you could create a screen video demonstrating it? Most likely, I missed some details. There is an https://uploads.jetbrains.com/ service for sharing files with JetBrains.
Do you get Build error when build a project with <Platforms>"Any CPU"</Platforms>? If yes, which MSBuild is set on the "
File | Settings | Build, Execution, Deployment | Toolset and Build" settings page?
I think it is from Rider Configuration Manager. (Edit Solution Configurations. The window is titled "Solution Properties - <SolutionName>")
If you have <Platform>x86</Platform> it will show that project in red and say "Configuration is defined in solution but does not exist in project". If you edit the project configurations from there to add Debug | x86 and select it, the Rider Configuration Manager will then add a duplicate <Platforms>x86</Platforms> tag.
So, the intellisense knows about <Platform> but not <Platforms> but the Configuration Manager knows about <Platforms> but not <Platform>.
I also notice that the configuration manager uses the text AnyCPU (with no space) when referring to the Any CPU platform. I'm not sure if the name AnyCPU is interchangeable with Any CPU or not. I'm pretty sure that VS uses the text Any CPU when referring to that platform. Perhaps they are synonyms but I'm not sure.
Well, I've outlined the steps required to reproduce this issue. This was the main thing I wanted to report, was the way a duplicate <Projects> tag is added and the way that <Platform> is ignored even though it's the only one the intellisense knows about.
Should I post this somewhere else?
Thank you very much for a detailed description of this issue.
Any CPU and AnyCPU are equivalents according to https://github.com/dotnet/project-system/issues/5737.
Also, I created an issue on Rider's tracker according to the description you shared: https://youtrack.jetbrains.com/issue/RIDER-68764
Could you please share your csproj and sln file here https://youtrack.jetbrains.com/issue/RIDER-68764 ?