SonghayCore Project Down to Eight Code Analysis Warnings!
The SonghayCore
Project is essentially the .NET 4+ version of the Songhay Project. As we’ve seen in a previous episode, SonghayCore
started this week with 147 Code Analysis warnings. Now, most of them have gone away. Here are the highlights:
- “CA1032: Implement standard exception constructors” is straightforward common sense—my ignorance deserves this warning.
- “CA2104: Do not declare read only mutable reference types”—this warning in my code is indicative of my lack of experience with certain embarrassingly intermediate topics. It inspires me to stay in shape with renewing study! “A mutable type is a type whose instance data can be modified. The
System.Text.StringBuilder
class is an example of a mutable reference type. It contains members that can change the value of an instance of the class.” - “CA1819: Properties should not return arrays” came for my code because I have types (like my OPML types) that need to be serialized into XML. I suppressed this warning. This is one of these intimate topics that someone relevant from Microsoft should address. “XmlSerialization and CA1819 Warning” is indicative of such intimacy.
- “CA1056: URI properties should not be strings” came (again) because of my OPML library and because of my support for Open Packaging Conventions URIs (used in Silverlight, WPF and other XAML-based technologies). I suppressed these.
- “CA1308: Normalize strings to uppercase” was suppressed because of my
ToTitleCase()
method inSonghay.Globalization.TextInfoUtility
. My official Justification: “This member is not making a security decision based on the result.” - “CA1006: Do not nest generic types in member signatures” comes a warning to me as Microsoft saying “you have bas taste”—I agree. So in shame I wrote a Collection class to avoid such nesting.
By the way, folks, that collection I wrote looks like this:
using System.Collections.ObjectModel;
namespace Songhay.Collections
{
using Models;
/// <summary>
/// Wrapper Collection for <see cref="Songhay.Models.RemoteResource"/>.
/// </summary>
public class RemoteResourceCollection : Collection<RemoteResource>
{
}
}
Based on precious hours of research, I assume that these, scant 13 lines of code is the appropriate alternative to the quite serious business dating back to 2009 in “Implementing IEnumerable and IEnumerator.” Even farther back on the timeline, in 2007, a Microsoft MVP from Skopje, Macedonia wrote “DecimalCollection.” This post shows how a custom collection should be based on CollectionBase
. However, in this part of the 21st century, CollectionBase
is considered obsolete under the influence of generics.