IDE0068 and IDE0018 have ruined all the fun

Hello,

I’m learning C# development and have a long list of commands I’m testing and developing. I can’t get my project to build now, as a number of my commands that used to work okay are now coming up with the IDE errors noted above.

First, I’d like to keep the variable declarations as they are, despite the suggestion to inline per 0018.

Second, it looks like I can suppress 0068, but would like to know what is causing the problem in the first place.

I have about 20 commands I’m working on and most are now showing these errors. Is there a ‘general’ approach to solving this problem?

Thanks,

Dan

There is no big recommendation on solving these particular problems.
Generally, these are just informational warnings, and you could just ignore them in this case.

The first two: here it’s about the garbage collector. It will still reclaim the memory for that go object, but it might be a little slower. No one will really notice it, because here it’s just two small objects. Read more about using.

using (var go = new GetObject())
{
  //code using 'go' goes here
}

The other two: if you want to inline the variable, you can double-clic on the warning in this list to show the line, and then use Intellisense: hover with the mouse cursor on the little ... logo that appears where there is the suggestion. Then click on the light bulb that appears.

Giulio,

Thanks for the reply. I’ve gone through and made the corrections on a couple commands. It’s time consuming, but I’ve fixed a few.

I’m still wondering what change I made that triggered all of these error messages though. In all the code examples that I’ve pulled from Rhino Developer Docs and GitHub I don’t see any use of ‘using’. I just followed a comprehensive course on C# plugin development for Rhino and it also wasn’t mentioned.

How can I avoid these IDE errors in the future?

Thanks,

Dan

These are not errors, but informational messages. Sometimes they are useful. Sometimes less. In particular, the first one is very useful in case of big objects that allocate a lot of memory and that therefore should be disposed of as quickly as possible. The second one is meant to make your code more legible.

A quick search showed a few topics:

Also, you can tick and untick these messages with the button highlighted here:
image

Giulio,

Thank you. I’m all clear on the differences between errors and messages now.

A message won’t cause a build to fail, but an error will, correct?

I’ll take more care of memory allocation once I have a clue what I’m doing.

Thanks,

Dan

1 Like