Avoiding Properties.Settings and Properties.Resources in Whidbey

Heya, I'm creating a custom rule for private class members variables. So far I'm using this code:

publicoverrideProblemCollection Check(TypeNode type)
...
foreach (Member memberin type.Members)
...
if (member.IsPrivate && member.NodeType ==NodeType.Field)
// Do check

Now, the problem here is that I get a lot of attributes which are in the Properties.Settings and Properties.Resources classes/files. Is there a way to check if the TypeNode is one of these classes? Now I use:

if (!type.FullName.EndsWith(".Properties.Settings"))

But I'm not too happy about it...

Cheers
/Chris

[1295 byte] By [compilator] at [2007-12-17]
# 1
Hi Chris,

Both these classes are decorated with the GeneratedCodeAttribute. This attribute has a tool name and a version number.

You could write a helper that checks for the existence of this attribute and check the toolname to be

"System.Resources.Tools.StronglyTypedResourceBuilder" or "Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator"

You don't want to ignore code marked this attribute all together, as ASP.NET and several other tools mark their generated code with this attribute as well, this generated code can contain chunks of user code inside it on which you probably do want to fire your rules.

Regards,
Jeffrey

JeffreyvanGogh at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Code Analysis and Code Metrics...

Visual Studio Team System

Site Classified