Link to home
Start Free TrialLog in
Avatar of CyberUnDead
CyberUnDead

asked on

FXCop Do not pass literals as localized parameters

I have developed an ASP.NET web application and I ran FXCop against my .dll in my bin directory.

I am receiving several Non Breaking "Do not pass literals as localized parameters" Errors.
Clicking on the link takes me to http://msdn2.microsoft.com/en-us/library/904d284e-76d0-4b8f-a4df-0094de8d7aac(vs.80).aspx but I am still not certain on how to correct this notice.

For instance this aspx page contains three buttons which in return redirects the user to the appropriate report depending upon what button they clicked.   The code below is flagged three times for the aforementioned "Do not pass literals..." error.  I am using VB.NET as my langauge of choice.

'---Begin Code---
    Protected Sub Report1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report1.Click
        Response.Redirect("~/Report/Report1.aspx")
    End Sub

    Protected Sub Report2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report2.Click
        Response.Redirect("~/Report/Report2.aspx")
    End Sub

    Protected Sub Report3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Report3.Click
        Response.Redirect("~/Report/Report3.aspx")
    End Sub
'---End Code---

What is the proper way to either code the above or eliminate the error message from FxCop?
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Here is a point from that article:

<Quote>It is safe to exclude a warning from this rule if the code library will not be localized, or if the string is not exposed to the end user or a developer using the code library.</Quote>

It is saying that you can ignore that warning.  If you want to deal with it, then you need to store the string in a resource file, and pull the value from there.

Bob
Avatar of CyberUnDead
CyberUnDead

ASKER

TheLearnedOne:

Thanks for the quick reply.  If I were to go with the second option of correcting the notice instead of ignoring it.  Do you have an example or tutorial on using resource files?  Does it make sense to do so since I do have about 70 notices of this particular error?
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial