OSDN Git Service

Dispose不要のメソッドにSuppressMessage属性を追加 (CA2000)
authorKimura Youichi <kim.upsilon@bucyou.net>
Sun, 13 Jul 2014 01:03:20 +0000 (10:03 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Mon, 21 Jul 2014 06:27:00 +0000 (15:27 +0900)
http://msdn.microsoft.com/ja-jp/library/ms182289.aspx

OpenTween/Connection/Networking.cs
OpenTween/EventViewerDialog.cs
OpenTween/MemoryImage.cs
OpenTween/ShortUrl.cs
OpenTween/TweetThumbnail.cs

index 8372fd6..dd8b012 100644 (file)
@@ -21,6 +21,7 @@
 
 using System;
 using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Net;
 using System.Net.Http;
@@ -68,6 +69,7 @@ namespace OpenTween.Connection
         private static ProxyType proxyType = ProxyType.IE;
         private static IWebProxy proxy = null;
 
+        [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
         static Networking()
         {
             DefaultTimeout = TimeSpan.FromSeconds(20);
@@ -119,6 +121,7 @@ namespace OpenTween.Connection
         /// 通常は Networking.Http を使用すべきです。
         /// このメソッドを使用する場合は、WebProxyChanged イベントが発生する度に HttpClient を生成し直すように実装してください。
         /// </remarks>
+        [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
         public static HttpClient CreateHttpClient(HttpClientHandler handler)
         {
             if (Networking.Proxy != null)
@@ -155,6 +158,7 @@ namespace OpenTween.Connection
                 throw new InvalidOperationException("Sequence error.(not initialized)");
         }
 
+        [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
         private static void OnWebProxyChanged(EventArgs e)
         {
             var newClient = Networking.CreateHttpClient(new HttpClientHandler());
index f5c80fc..d8e6c58 100644 (file)
@@ -28,6 +28,7 @@ using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
+using System.Diagnostics.CodeAnalysis;
 using System.Drawing;
 using System.Linq;
 using System.Text;
@@ -276,6 +277,7 @@ namespace OpenTween
             }
         }
 
+        [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
         private static IEnumerable<TabPage> CreateTabsFromUserStreamsEvent()
         {
             return Enum.GetNames(typeof(MyCommon.EVENTTYPE))
index 52fd8e8..05180f9 100644 (file)
@@ -25,6 +25,7 @@ using System.Linq;
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
 using System.Text;
+using System.Diagnostics.CodeAnalysis;
 using System.Drawing;
 using System.IO;
 using System.Threading.Tasks;
@@ -151,6 +152,7 @@ namespace OpenTween
         /// <param name="stream">読み込む対象となる Stream</param>
         /// <returns>作成された MemoryImage</returns>
         /// <exception cref="InvalidImageException">不正な画像データが入力された場合</exception>
+        [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
         public static MemoryImage CopyFromStream(Stream stream)
         {
             var memstream = new MemoryStream();
@@ -185,6 +187,7 @@ namespace OpenTween
         /// <param name="bytes">読み込む対象となるバイト列</param>
         /// <returns>作成された MemoryImage</returns>
         /// <exception cref="InvalidImageException">不正な画像データが入力された場合</exception>
+        [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
         public static MemoryImage CopyFromBytes(byte[] bytes)
         {
             return new MemoryImage(new MemoryStream(bytes));
index 50a3b93..79f4187 100644 (file)
@@ -27,6 +27,7 @@
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using System.Net.Http;
 using System.Text;
@@ -127,6 +128,7 @@ namespace OpenTween
             _instance = new Lazy<ShortUrl>(() => new ShortUrl(), true);
         }
 
+        [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
         internal ShortUrl()
             : this(CreateDefaultHttpClient())
         {
@@ -491,6 +493,7 @@ namespace OpenTween
             }
         }
 
+        [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
         private static HttpClient CreateDefaultHttpClient()
         {
             var handler = new HttpClientHandler
index a4a5dd8..d25d936 100644 (file)
@@ -22,6 +22,7 @@
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
+using System.Diagnostics.CodeAnalysis;
 using System.Drawing;
 using System.Data;
 using System.Linq;
@@ -159,6 +160,7 @@ namespace OpenTween
             }
         }
 
+        [SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope")]
         protected virtual OTPictureBox CreatePictureBox(string name)
         {
             return new OTPictureBox()