5cover/Dialogs

View on GitHub
Dialogs/ComCtlv6ActivationContext.cs

Summary

Maintainability
A
0 mins
Test Coverage

Incorrect end of line character(s) found.
Open

// Unless required by applicable law or agreed to in writing, software distributed under the License is

Incorrect end of line character(s) found.
Open

using System.Reflection;

Incorrect end of line character(s) found.
Open

    public void Dispose()

Incorrect end of line character(s) found.
Open

        contents.CopyTo(file);

Incorrect end of line character(s) found.
Open

using static Vanara.PInvoke.Kernel32;

Incorrect end of line character(s) found.
Open

        _cookie.Dispose();

Incorrect end of line character(s) found.
Open

    }

Incorrect end of line character(s) found.
Open

    }

Incorrect end of line character(s) found.
Open

        activationContext.Value?.Dispose();

Incorrect end of line character(s) found.
Open

        lock (contextCreationLock)

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

            return Win32Error.ThrowLastErrorIfInvalid(CreateActCtx(new ACTCTX(CreateTempFile(xpThemes))));

Incorrect end of line character(s) found.
Open

// - Used Lazy<T> to simplify logic

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

using Vanara.InteropServices;

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    private static readonly object contextCreationLock = new();

Incorrect end of line character(s) found.
Open

    {

Incorrect end of line character(s) found.
Open

// with the License. You may obtain a copy of the License at

Incorrect end of line character(s) found.
Open

// Changes:

Incorrect end of line character(s) found.
Open

// - Use default as NULL pointer constant

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    {

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    {

Incorrect end of line character(s) found.
Open

    }

Incorrect end of line character(s) found.
Open

// Original:

Incorrect end of line character(s) found.
Open

// - Adapted to Vanara semantics (safe handles and Win32Error)

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

internal sealed class ComCtlV6ActivationContext : IDisposable

Incorrect end of line character(s) found.
Open

        _cookie = new(cookie, static ptr => Win32Error.ThrowLastErrorIfFalse(DeactivateActCtx(default, ptr), "ComCtl32 V6 activation context deactivation failed."));

Incorrect end of line character(s) found.
Open

    private static readonly Lazy<SafeHACTCTX> activationContext = new(CreateActivationContext, true);

Incorrect end of line character(s) found.
Open

    {

Incorrect end of line character(s) found.
Open

    private static SafeHACTCTX CreateActivationContext()

Incorrect end of line character(s) found.
Open

        {

Incorrect end of line character(s) found.
Open

// https://github.com/ookii-dialogs/ookii-dialogs-wpf/blob/master/src/Ookii.Dialogs.Wpf/ComCtlv6ActivationContext.cs

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

// See the License for the specific language governing permissions and limitations under the License.

Incorrect end of line character(s) found.
Open

            using var xpThemes = Assembly.GetExecutingAssembly().GetManifestResourceStream($"{nameof(Scover)}.{nameof(Dialogs)}.XPThemes.manifest").AssertNotNull();

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    private static string CreateTempFile(Stream contents)

Incorrect end of line character(s) found.
Open

// https://opensource.org/licenses/BSD-3-Clause

Incorrect end of line character(s) found.
Open

using Vanara.PInvoke;

Incorrect end of line character(s) found.
Open

    }

Incorrect end of line character(s) found.
Open

//

Incorrect end of line character(s) found.
Open

namespace Scover.Dialogs;

Incorrect end of line character(s) found.
Open

{

Incorrect end of line character(s) found.
Open

        }

Incorrect end of line character(s) found.
Open

// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in compliance

Incorrect end of line character(s) found.
Open

// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

    private readonly GenericSafeHandle _cookie;

Incorrect end of line character(s) found.
Open

        _ = Win32Error.ThrowLastErrorIfFalse(ActivateActCtx(activationContext.Value, out nint cookie), "ComCtl32 V6 activation context activation failed.");

Incorrect end of line character(s) found.
Open

        return file.Name;

Incorrect end of line character(s) found.
Open

//

Incorrect end of line character(s) found.
Open

// - Adapted the code to use Vanara.

Incorrect end of line character(s) found.
Open

    public ComCtlV6ActivationContext()

Incorrect end of line character(s) found.
Open


Incorrect end of line character(s) found.
Open

        using FileStream file = new(Path.GetTempFileName(), FileMode.Open);

There are no issues that match your filters.

Category
Status