I'm having a couple of FxCop errors that I don't really know how to fix. Well, I do know how to fix them, but I don't really like the solutions I can think of...
[CLSCompliantAttribute(true)]
[AttributeUsage(AttributeTargets.Property)]
public sealed class LightSettingsAttribute : Attribute {
private string sectionName;
private object defaultValue;
public string SectionName {
get {
return this.sectionName;
}
}
public object DefaultValue {
get {
return this.defaultValue;
}
}
public LightSettingsAttribute(String sectionName, Type valueType, string defaultValue) {
this.sectionName = sectionName;
this.defaultValue = TypeDescriptor.GetConverter(valueType).ConvertFromInvariantString(defaultValue);
}
}
I would fix it by creating a public readonly property and then set the private value (that the property returns) to the variable valueType passed as parameter of the constructor and then use the property value in the GetConverter() method. But this is stupid... I only need to use valueType on the GetConverter() inside the constructor, I don't need to save the value of valueType.
I checked similar code in the framework (using Reflector) and Microsoft doesn't do that, it simply uses the parameter value as I did. Anyway to go around this issue?
Basically this is how I'm handling some exception:
try {
} catch (Exception ex) {
}
I'm doing this because no matter what the CLS compilant exception thrown I need the piece of code inside the catch block to be executed. I can't go and catch each individual exception and duplicate the code (yes, I could put it in a method but I was looking to avoid that if possible). Maybe only 2 out of a few exceptions will actually be thrown (if they are) but either way, is there some way to catch multiple exceptions and use the same catch block?
They need to follow the standard for AAA game but they will go at lowest level for triple a game because will sell more, earn kudos and the milk it for years anyway.
look how much they milked gta 5 and how they milked the original 3 - San Andreas and vice city.
it is probably going to be a fun game but then they allowed someone to remake classics that somehow were more broken and worse then original
i hope they don’t ###### up this one!!!
In addition to the "sidebar app list" and "Collections" features, Microsoft will also deprecate the "Drop" feature. Before you publish this news and credit another site, here is the original source:
https://x.com/i/status/2067838711870439583
.
Question
ProclaimDragon
Hi,
I'm having a couple of FxCop errors that I don't really know how to fix. Well, I do know how to fix them, but I don't really like the solutions I can think of...
The errors I'm having are:
[suppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
Code causing the error:
[CLSCompliantAttribute(true)] [AttributeUsage(AttributeTargets.Property)] public sealed class LightSettingsAttribute : Attribute { private string sectionName; private object defaultValue; public string SectionName { get { return this.sectionName; } } public object DefaultValue { get { return this.defaultValue; } } public LightSettingsAttribute(String sectionName, Type valueType, string defaultValue) { this.sectionName = sectionName; this.defaultValue = TypeDescriptor.GetConverter(valueType).ConvertFromInvariantString(defaultValue); } }I would fix it by creating a public readonly property and then set the private value (that the property returns) to the variable valueType passed as parameter of the constructor and then use the property value in the GetConverter() method. But this is stupid... I only need to use valueType on the GetConverter() inside the constructor, I don't need to save the value of valueType.
I checked similar code in the framework (using Reflector) and Microsoft doesn't do that, it simply uses the parameter value as I did. Anyway to go around this issue?
[suppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
Basically this is how I'm handling some exception:
try {
} catch (Exception ex) {
}
I'm doing this because no matter what the CLS compilant exception thrown I need the piece of code inside the catch block to be executed. I can't go and catch each individual exception and duplicate the code (yes, I could put it in a method but I was looking to avoid that if possible). Maybe only 2 out of a few exceptions will actually be thrown (if they are) but either way, is there some way to catch multiple exceptions and use the same catch block?
Link to comment
https://www.neowin.net/forum/topic/647227-suggestions-to-fix-a-couple-of-fxcop-errors/Share on other sites
4 answers to this question
Recommended Posts