Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
<MicrosoftCodeAnalysisVersion_4_4>4.4.0</MicrosoftCodeAnalysisVersion_4_4>
<!-- Compatibility with VS 17.8/.NET SDK 8.0.1xx -->
<MicrosoftCodeAnalysisVersion_4_8>4.8.0</MicrosoftCodeAnalysisVersion_4_8>
<!-- Compatibility with VS 18.0/.NET SDK 10.0.1xx -->
<MicrosoftCodeAnalysisVersion_5_0>5.0.0-2.26070.104</MicrosoftCodeAnalysisVersion_5_0>
<!-- Compatibility with the latest Visual Studio Preview release -->
<!--
The exact version is always a moving target. This version should never go ahead of the version of Roslyn that is included in the most recent
Expand All @@ -74,7 +76,7 @@
Source-build builds the product with the most recent previously source-built release. Thankfully, these two requirements line up nicely
such that any version that satisfies the VS version requirement will also satisfy the .NET SDK version requirement because of how we ship.
-->
<MicrosoftCodeAnalysisVersion_LatestVS>4.14.0</MicrosoftCodeAnalysisVersion_LatestVS>
<MicrosoftCodeAnalysisVersion_LatestVS>5.4.0-2.26060.102</MicrosoftCodeAnalysisVersion_LatestVS>
<!-- Some of the analyzer dependencies used by ILLink project -->
<MicrosoftCodeAnalysisBannedApiAnalyzersVersion>3.3.5-beta1.23270.2</MicrosoftCodeAnalysisBannedApiAnalyzersVersion>
</PropertyGroup>
Expand Down
7 changes: 2 additions & 5 deletions src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,11 +1351,8 @@ internal static IntPtr AddToCleanupList(ref CleanupWorkListElement? pCleanupWork

internal static void DestroyCleanupList(ref CleanupWorkListElement? pCleanupWorkList)
{
if (pCleanupWorkList != null)
{
pCleanupWorkList.Destroy();
pCleanupWorkList = null;
}
pCleanupWorkList?.Destroy();
pCleanupWorkList = null;
}

internal static Exception GetHRExceptionObject(int hr)
Expand Down
7 changes: 2 additions & 5 deletions src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,8 @@ public void SetParentHandle(SafeAlgorithmHandle parentHandle)

protected sealed override bool ReleaseHandle()
{
if (_parentHandle != null)
{
_parentHandle.DangerousRelease();
_parentHandle = null;
}
_parentHandle?.DangerousRelease();
_parentHandle = null;

uint ntStatus = BCryptDestroyKey(handle);
return ntStatus == 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ public SafeWinHttpHandle() : base(true)

public static void DisposeAndClearHandle(ref SafeWinHttpHandle? safeHandle)
{
if (safeHandle != null)
{
safeHandle.Dispose();
safeHandle = null;
}
safeHandle?.Dispose();
safeHandle = null;
}

public void SetParentHandle(SafeWinHttpHandle parentHandle)
Expand All @@ -47,11 +44,8 @@ public void SetParentHandle(SafeWinHttpHandle parentHandle)
// calls in progress.
protected override bool ReleaseHandle()
{
if (_parentHandle != null)
{
_parentHandle.DangerousRelease();
_parentHandle = null;
}
_parentHandle?.DangerousRelease();
_parentHandle = null;

return Interop.WinHttp.WinHttpCloseHandle(handle);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ protected override bool ReleaseHandle()
// release the addref we took in SetDictionary
_dictionary?.DangerousRelease();

if (_prefixHandle != null)
{
_prefixHandle.Value.Dispose();
_prefixHandle = null;
}
_prefixHandle?.Dispose();
_prefixHandle = null;
return true;
}

Expand Down Expand Up @@ -74,11 +71,8 @@ public unsafe void Reset()
ZstandardUtils.ThrowIfError(Interop.Zstd.ZSTD_CCtx_reset(this, Interop.Zstd.ZstdResetDirective.ZSTD_reset_session_only));

// prefix is not sticky and is cleared by reset
if (_prefixHandle != null)
{
_prefixHandle.Value.Dispose();
_prefixHandle = null;
}
_prefixHandle?.Dispose();
_prefixHandle = null;
}

public override bool IsInvalid => handle == IntPtr.Zero;
Expand All @@ -97,11 +91,8 @@ protected override bool ReleaseHandle()
// release the addref we took in SetDictionary
_dictionary?.DangerousRelease();

if (_prefixHandle != null)
{
_prefixHandle.Value.Dispose();
_prefixHandle = null;
}
_prefixHandle?.Dispose();
_prefixHandle = null;
return true;
}

Expand Down Expand Up @@ -149,11 +140,8 @@ public unsafe void Reset()
ZstandardUtils.ThrowIfError(Interop.Zstd.ZSTD_DCtx_reset(this, Interop.Zstd.ZstdResetDirective.ZSTD_reset_session_only));

// prefix is not sticky and is cleared by reset
if (_prefixHandle != null)
{
_prefixHandle.Value.Dispose();
_prefixHandle = null;
}
_prefixHandle?.Dispose();
_prefixHandle = null;
}

public override bool IsInvalid => handle == IntPtr.Zero;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,8 @@ public void Dispose()
{
_disposed = true;

if (_hash != null)
{
_hash.Dispose();
_hash = null;
}
_hash?.Dispose();
_hash = null;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,12 @@ private void ExportKey(
keyBytes.Length != expectedKeySize ||
!parameterSet.SequenceEqual(expectedParameterSet))
{
#pragma warning disable IDE0071
Debug.Fail(
$"{nameof(blobType)}: {blobType}, " +
$"{nameof(parameterSet)}: {parameterSet.ToString()}, " +
$"{nameof(keyBytes)}.Length: {keyBytes.Length} / {expectedKeySize}");
#pragma warning restore IDE0071

throw new CryptographicException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,12 @@ private void ExportKey(string keyBlobType, int expectedKeySize, Span<byte> desti
keyBytes.Length != expectedKeySize ||
!parameterSet.SequenceEqual(expectedParameterSet))
{
#pragma warning disable IDE0071
Debug.Fail(
$"{nameof(blobType)}: {blobType}, " +
$"{nameof(parameterSet)}: {parameterSet.ToString()}, " +
$"{nameof(keyBytes)}.Length: {keyBytes.Length} / {expectedKeySize}");
#pragma warning restore IDE0071

throw new CryptographicException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ public override int KeySize

ThrowIfDisposed();

if (_keys != null)
{
_keys.Dispose();
_keys = null;
}
_keys?.Dispose();
_keys = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,11 @@ protected virtual void Dispose(bool disposing)
}
finally
{
if (catalogToUnsubscribeFrom != null)
{
catalogToUnsubscribeFrom.Changing -= OnCatalogChanging;
}
catalogToUnsubscribeFrom?.Changing -= OnCatalogChanging;

aggregateExportProvider?.Dispose();

if (sourceProvider != null)
{
sourceProvider.ExportsChanging -= OnExportsChangingInternal;
}
sourceProvider?.ExportsChanging -= OnExportsChangingInternal;

importEngine?.Dispose();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ internal CompositionService(ComposablePartCatalog composablePartCatalog)
_notifyCatalog = composablePartCatalog as INotifyComposablePartCatalogChanged;
try
{
if (_notifyCatalog != null)
{
_notifyCatalog.Changing += OnCatalogChanging;
}
_notifyCatalog?.Changing += OnCatalogChanging;

var compositionOptions = CompositionOptions.DisableSilentRejection | CompositionOptions.IsThreadSafe | CompositionOptions.ExportCompositionService;
var compositionContainer = new CompositionContainer(composablePartCatalog, compositionOptions);
Expand All @@ -36,10 +33,7 @@ internal CompositionService(ComposablePartCatalog composablePartCatalog)
}
catch
{
if (_notifyCatalog != null)
{
_notifyCatalog.Changing -= OnCatalogChanging;
}
_notifyCatalog?.Changing -= OnCatalogChanging;
throw;
}
}
Expand All @@ -62,10 +56,7 @@ public void Dispose()
}

// Delegates are cool there is no concern if you try to remove an item from them and they don't exist
if (_notifyCatalog != null)
{
_notifyCatalog.Changing -= OnCatalogChanging;
}
_notifyCatalog?.Changing -= OnCatalogChanging;
_compositionContainer.Dispose();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,7 @@ protected virtual void Dispose(bool disposing)
}
}

if (sourceProviderToUnsubscribeFrom != null)
{
sourceProviderToUnsubscribeFrom.ExportsChanging -= OnExportsChanging;
}
sourceProviderToUnsubscribeFrom?.ExportsChanging -= OnExportsChanging;

if (disposeLock)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,8 @@ private static bool ValidateInternalRecursive(LicenseContext context, Type type,
#pragma warning restore IDE0059
}
isValid = ValidateInternalRecursive(context, baseType, null, allowExceptions, out license, out _);
if (license != null)
{
license.Dispose();
license = null;
}
license?.Dispose();
license = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,8 @@ public void Close()
_delayedEnable = false;
_enabled = false;

if (_timer != null)
{
_timer.Dispose();
_timer = null;
}
_timer?.Dispose();
_timer = null;
}

protected override void Dispose(bool disposing)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,8 @@ public override void Load(string filename)
}
finally
{
if (_reader != null)
{
_reader.Close();
_reader = null;
}
_reader?.Close();
_reader = null;
}
}

Expand All @@ -82,11 +79,8 @@ public void LoadSingleElement(string filename, XmlTextReader sourceReader)
}
finally
{
if (_reader != null)
{
_reader.Close();
_reader = null;
}
_reader?.Close();
_reader = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,8 @@ public override void Load(string filename)
}
finally
{
if (_reader != null)
{
_reader.Close();
_reader = null;
}
_reader?.Close();
_reader = null;
}
}

Expand All @@ -66,11 +63,8 @@ private void LoadFromConfigXmlReader(ConfigXmlReader reader)
}
finally
{
if (_reader != null)
{
_reader.Close();
_reader = null;
}
_reader?.Close();
_reader = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,8 @@ private void ReleaseResources()

_stream = null;

if (_cachedStringWriter != null)
{
_cachedStringWriter.Close();
_cachedStringWriter = null;
}
_cachedStringWriter?.Close();
_cachedStringWriter = null;
}

// Read until the Next Element element, or we hit
Expand Down
21 changes: 6 additions & 15 deletions src/libraries/System.Data.Common/src/System/Data/DataTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1701,21 +1701,12 @@ public DataColumn[] PrimaryKey
oldKey.ConstraintIndex.RemoveRef();

// if PrimaryKey is removed, reset LoadDataRow indexes
if (null != _loadIndex)
{
_loadIndex.RemoveRef();
_loadIndex = null;
}
if (null != _loadIndexwithOriginalAdded)
{
_loadIndexwithOriginalAdded.RemoveRef();
_loadIndexwithOriginalAdded = null;
}
if (null != _loadIndexwithCurrentDeleted)
{
_loadIndexwithCurrentDeleted.RemoveRef();
_loadIndexwithCurrentDeleted = null;
}
_loadIndex?.RemoveRef();
_loadIndex = null;
_loadIndexwithOriginalAdded?.RemoveRef();
_loadIndexwithOriginalAdded = null;
_loadIndexwithCurrentDeleted?.RemoveRef();
_loadIndexwithCurrentDeleted = null;
Constraints.Remove(oldKey);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,8 @@ private void AssertConstraintAndKeyIndexes()

internal void ConstraintIndexClear()
{
if (null != _constraintIndex)
{
_constraintIndex.RemoveRef();
_constraintIndex = null;
}
_constraintIndex?.RemoveRef();
_constraintIndex = null;
}

internal void ConstraintIndexInitialize()
Expand Down
Loading
Loading