0

Structural Search to find ViewState assignment

I'd like to create a structural search to find where non-value types are assigned to ViewState,

eg

    private List<string> UnitsOfMeasure
    {
        get
        {
            if (ViewState["uom"] == null) ViewState["uom"] = new List<string>();
            return (List<string>)ViewState["uom"];
        }
        set
        {
            ViewState["uom"] = value;
        }
    }


The following finds it
ViewState[$key$] = $value$

but also finds lots where the type being assigned is a string or other value type.
I want to identify these so that I can check they are serialisable.

I have $value$ as an identifier, but if I could have it as an expression of type "[^String|Guid|int|etc]"
or some such syntax?

Perhaps I need to investigate writing a plugin for this?

3 comments

Please sign in to leave a comment.