<commit_before>// Copyright © <NAME> and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.	

using TerraFX.Interop;
using static TerraFX.Interop.Windows;
using static TerraFX.Utilities.ExceptionUtilities;

namespace TerraFX.Graphics.Providers.D3D12
{
    internal static unsafe partial class HelperUtilities
    {
        public static void ReleaseIfNotNull<TUnknown>(TUnknown* unknown)
            where TUnknown : unmanaged
        {
            if (unknown != null)
            {
                _ = ((IUnknown*)unknown)->Release();
            }
        }

        public static void ThrowExternalExceptionIfFailed(string methodName, int hr)
        {
            if (FAILED(hr))
            {
                ThrowExternalException(methodName, hr);
            }
        }
    }
}<commit_msg>Adding a ReleaseIfCreated helper utility method<commit_after>// Copyright © <NAME> and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information.	

using TerraFX.Interop;
using TerraFX.Utilities;
using static TerraFX.Interop.Windows;
using static TerraFX.Utilities.ExceptionUtilities;

namespace TerraFX.Graphics.Providers.D3D12
{
    internal static unsafe partial class HelperUtilities
    {
        public static void ReleaseIfCreated<TUnknown>(ValueLazy<Pointer<TUnknown>> unknown)
            where TUnknown : unmanaged
        {
            if (unknown.IsCreated)
            {
                ReleaseIfNotNull<TUnknown>(unknown.Value);
            }
        }

        public static void ReleaseIfNotNull<TUnknown>(TUnknown* unknown)
            where TUnknown : unmanaged
        {
            if (unknown != null)
            {
                _ = ((IUnknown*)unknown)->Release();
            }
        }

        public static void ThrowExternalExceptionIfFailed(string methodName, int hr)
        {
            if (FAILED(hr))
            {
                ThrowExternalException(methodName, hr);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.07898586055582643, 'fraction_numerical': 0.0029254022428083864, 'mean_word_length': 2.1280487804878048, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3516008', 'n_tokens_mistral': 522, 'n_tokens_neox': 518, 'n_words': 138}