lock (typeof (SqlMapper))
{
...
}
程式碼分析給出了 CA2002
不知道為什麼會寫出 lock typeof object的東西,這樣真的能鎖住東西?
lock (typeof (SqlMapper))
{
...
}
using (StreamReader sr = new StreamReader(inputStream))
{
using (CsvReader csvReader = new CsvReader(sr))
{
..
}
}
就會出現警告 CA2202:不要多次處置物件的 Dispose方法If an object's Dispose method is called more than once, the object must ignore all calls after the first one. The object must not throw an exception if its Dispose method is called multiple times. Instance methods other than Dispose can throw an ObjectDisposedException when resources are already disposed.
[SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times")]
public byte[] FunctionName(...) {