Was FxCop wrong to tell me to use the .Net Uri class?

Upon receiving the URL for something in the Amazon S3 bucket, he can add a signature to the end to confirm that the user has permission to view the object, and the URL looks like this:

https://mybucket.amazonaws.com/mykey?AWSAccessKeyId=myaccesskey& Expires = 1235241261 & Signature = t5vFBWXaN0DvVaWfck9n2% 2fmTzOU% 3d

These URLs were returned from my S3 library as string objects, and I passed them like this. I recently ran my code through FxCop and recommended using a class Urito pass URLs. I made a FxCops decision and changed the URL stringproperties to properties Uri. Everything seemed to work fine until I noticed that not all objects were successfully returned.

The cause of the problem was that the Uriclass function ToString()would return a slightly different version of the URL:

https://mybucket.amazonaws.com/mykey?AWSAccessKeyId=myaccesskey& Expires = 1235241261 & Signature = t5vFBWXaN0DvVaWfck9n2 / mTzOU =

My solution was to use a OriginalStringclass property Uri. But there is something wrong with this, and I have two questions:

  • FxCops Uri?
  • Amazon , URL- , ?

.Net Uri- , URL- , , , .

+3
2

FxCop Uri . Uri .

System.Uri . , , . , URI HTTP.

wikipedia, percent-encoding URL- .

, %2f - escape- URL- /. System.Uri .

System.Uri, , . Uri .

+4

Source: https://habr.com/ru/post/1703625/


All Articles