Rule SA1126 not firing for "var str = ViewState["SiteMapProvider"] as string;"

Oct 16, 2012 at 3:57 PM

In the following code behind an aspx page

    /// <summary>
    /// Gets or sets the site map provider.
    /// </summary>
    /// <value>The site map provider.</value>
    protected virtual string SiteMapProvider
    {
      get
      {
        var str = ViewState["SiteMapProvider"] as string;
        return str ?? string.Empty;
      }

      set
      {
        this.ViewState["SiteMapProvider"] = value;
      }
    }

The ViewState in "var str = ViewState["SiteMapProvider"] as string;" does not fire SA1126!

p.s. your spellchecker should recognise aspx and aspnet!

Oct 9, 2013 at 9:55 AM
This is still an issue even with the latest StyleCop (4.7.46.0).