Code Inspection flags open generics in config as INCORRECT_TYPE_PARAMETER_NUMBER

We need to specify an open generic type name on our web.config file, but when Resharper's Code Inspection is executed, it flags the type declarations with this 'INCORRECT_TYPE_PARAMETER_NUMBER' error.

As I understand it, writting a open generic type like this is supported by the CLR, so it should be also a valid case for Resharper.

For instance, this is one of the offending lines:

<handleDef id="memoryCache" type="CacheManager.SystemRuntimeCaching.MemoryCacheHandle`1, CacheManager.SystemRuntimeCaching" />


The corresponding class correctly has a single type parameter:

public class MemoryCacheHandle<T> : BaseCache<T> where T : class



The whole "MemoryCacheHandle`1" text is underlined in red, and I get an inspection error (cathegory 'XML Errors') with the message being only "INCORRECT_TYPE_PARAMETER_NUMBER".

Perhaps we are looking at two distinct issues here:

  1. Code Inspection wrongly prohibits open generic type string representations in the config files, even though they are valid .Net constructs
  2. The message for incorrect number of type arguments seems to be missing


Since we integrated inspectcode.exe in our build validation process, the partially succeded builds are starting to get annoying.

I'd love to hear a way to make this work as intended.
Juliano

7 comments
Comment actions Permalink

It appears that ReSharper doesn't support open generics. If you change your declaration to something like:

<handleDef id="memoryCache" type="CacheManager.SystemRuntimeCaching.MemoryCacheHandler`1[System.String], CacheManager.SystemRuntimeCaching" />


then the highlight goes away. This has been reported before - here's the issue tracker link, so you can vote, track and add any details that might be useful: http://youtrack.jetbrains.com/issue/RSRP-349986

And while it's kind of covered by that issue, I've also opened a distinct ticket for the non-friendly error message: http://youtrack.jetbrains.com/issue/RSRP-416082

0
Comment actions Permalink

I'm very sorry but I wasn't able to find the bug you posted, it really is the exact same issue, although it was filled a bit more specific (in Unity's context) than needed.

Won't I break things if I specify a type there? I mean, it won't be an open generic type anymore. I assume there is no other workaround for it?

0
Comment actions Permalink

Right, sorry, I was just indicating that it seems to be ReSharper's issue - it's expecting a closed generic. There isn't a workaround right now, other than to ignore the warning.

0
Comment actions Permalink

I see. While I wait for the fix, I think I'll have to patch my own parser to ignore this error. Fortunatelly, I'm in control of that part of the process, so our build will not be marked as 'Partially Succeded' anymore. It's still a shame that the error pops up on the developers machines though, I can already see the confusion this will cause.

Anyways, thanks a lot for the support Matt.

Juliano

0
Comment actions Permalink

You should be able to ignore the warning by changing its severity from the alt+enter menu. You can set it to hint, suggestion, warning or even turn it off completely. This should get saved to the solution file settings, so each team member would get the change, too.

0
Comment actions Permalink

That would be great, but when I hit alt+enter I only get two options: "Remove attribute" and "Expand empty tag", which is the default actions, not related to the error at all.

I tried to find this error in the Code Inspection->Severity dialog, but nothing of the sort shows there.

There really seems to be quite a few bugs around this inspection...

I wonder if I could suppress it by editing the .dotSettings file manually. Will give this a shot, just need to now the format it generates.

EDIT: Yeah, putting it manually on the .dotSettings file did not work at all. I'm probably missing the correct name for the issue, but I don't know how to find that information.

0
Comment actions Permalink

Hmm. No, annoyingly, the way this is implemented is as an invalid reference. That is, the text "Foo`1" should be a reference to a type. Because this reference doesn't resolve (since it's looking for a closed type reference), it's marked as invalid, and highlighted. All of which is a way of saying that it's not an inspection that can be disabled or ignored. This is why there isn't a context menu item to disable, and it also means it can't be added manually into the .dotSettings file. Unfortunately, there's no workaround that will hide the warning, sorry.

0

Please sign in to leave a comment.