vb.net - Do not pass literals as localized parameters -


i have following warning when running code analysis on project (which windows phone 8.1 app):

ca1303 not pass literals localized parameters method 'common.translateerror(string)' passes literal string parameter 'text' of call 'xdocument.parse(string)'. retrieve following string(s) resource table instead.

this method:

public function translateerror(byval exmessage string) xdocument      return xdocument.parse("<response><exception><message><" & xmlconvert.encodename(exmessage) & "></message></exception></response>")  end function 

the code works , it's not i've had address since adding code warning makes me believe i'm not doing quite right.

i've done research , found msdn acticle ca1303: not pass literals localized parameters can't reference resourcemanager. if reference still wouldn't understand why problem when passing string xdocument.parse.

i want address warning , not suppress it. has got ideas how can fix or why such warning exists?

should want replicate need configure rule set use microsoft rules:

enter image description here

then run analysis select analyze visual studio menu , choose run code analysis on...

as suggested @ryanroos piece of code resolved warning:

public function translateerror(byval exmessage string) xdocument      dim sb new stringbuilder("<response><exception><message><![cdata[" & xmlconvert.encodename(exmessage) & "]]></message></exception></response>")      return xdocument.parse(sb.tostring())  end function 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -