Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix review comments
  • Loading branch information
YuliiaKovalova committed Apr 19, 2024
commit 0c12087311de31a41cdcc5e8ff51bf6521ff5b0c
3 changes: 0 additions & 3 deletions eng/Common.globalconfig
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,6 @@ dotnet_diagnostic.CA1837.severity = suggestion
# Avoid 'StringBuilder' parameters for P/Invokes
dotnet_diagnostic.CA1838.severity = warning

# Dispose objects before losing scope
dotnet_diagnostic.CA2000.severity = none

# Do not lock on objects with weak identity
dotnet_diagnostic.CA2002.severity = none

Expand Down
3 changes: 3 additions & 0 deletions src/Deprecated/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# Dispose objects before losing scope
dotnet_diagnostic.CA2000.severity = none
2 changes: 1 addition & 1 deletion src/Framework/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ internal static List<KeyValuePair<int, SafeProcessHandle>> GetChildProcessIds(in
{
// Hold the child process handle open so that children cannot die and restart with a different parent after we've started looking at it.
// This way, any handle we pass back is guaranteed to be one of our actual children.
#pragma warning disable CA2000 // Dispose objects before losing scope by design
#pragma warning disable CA2000 // Dispose objects before losing scope - caller must dispose returned handles
SafeProcessHandle childHandle = OpenProcess(eDesiredAccess.PROCESS_QUERY_INFORMATION, false, possibleChildProcess.Id);
#pragma warning restore CA2000 // Dispose objects before losing scope
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tasks/DownloadFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private async Task<bool> ExecuteAsync()
private async Task DownloadAsync(Uri uri, CancellationToken cancellationToken)
{
// The main reason to use HttpClient vs WebClient is because we can pass a message handler for unit tests to mock
#pragma warning disable CA2000 // Dispose objects before losing scope because the HttpClient is disposed by HTTPClient.Dispose()
#pragma warning disable CA2000 // Dispose objects before losing scope because HttpClientHandler is disposed by HTTPClient.Dispose()
using (var client = new HttpClient(HttpMessageHandler ?? new HttpClientHandler(), disposeHandler: true) { Timeout = TimeSpan.FromMilliseconds(Timeout) })
{
// Only get the response without downloading the file so we can determine if the file is already up-to-date
Expand Down
4 changes: 1 addition & 3 deletions src/Tasks/ManifestUtil/ManifestWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ private static Stream Serialize(Manifest manifest)
manifest.OnBeforeSave();
var m = new MemoryStream();
var s = new XmlSerializer(manifest.GetType());
#pragma warning disable CA2000 // Dispose objects before losing scope is suppressed because the stream is returned to the caller and will be handled there.
var w = new StreamWriter(m);
#pragma warning restore CA2000 // Dispose objects before losing scope
using var w = new StreamWriter(m, System.Text.Encoding.UTF8, bufferSize: 1024, leaveOpen: true);

int t1 = Environment.TickCount;
s.Serialize(w, manifest);
Expand Down
5 changes: 1 addition & 4 deletions src/Tasks/WriteCodeFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,7 @@ private string GenerateCode(out string extension)
}
finally
{
if (provider != null)
{
provider.Dispose();
}
provider?.Dispose();
}
}

Expand Down