< Summary

Class:Azure.Identity.WindowsVisualStudioCodeAdapter
Assembly:Azure.Identity
File(s):C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\WindowsVisualStudioCodeAdapter.cs
Covered lines:8
Uncovered lines:0
Coverable lines:8
Total lines:31
Line coverage:100% (8 of 8)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.cctor()-100%100%
GetUserSettingsPath()-100%100%
GetCredentials(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\identity\Azure.Identity\src\WindowsVisualStudioCodeAdapter.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.ComponentModel;
 6using System.IO;
 7using System.Runtime.InteropServices;
 8
 9namespace Azure.Identity
 10{
 11    internal sealed class WindowsVisualStudioCodeAdapter : IVisualStudioCodeAdapter
 12    {
 213        private static readonly string s_userSettingsJsonPath = Path.Combine(Environment.GetFolderPath(Environment.Speci
 14
 4815        public string GetUserSettingsPath() => s_userSettingsJsonPath;
 16
 17        public string GetCredentials(string serviceName, string accountName)
 18        {
 4819            IntPtr credentials = WindowsNativeMethods.CredRead($"{serviceName}/{accountName}", WindowsNativeMethods.CRED
 20            try
 21            {
 4822                WindowsNativeMethods.CredentialData credData = Marshal.PtrToStructure<WindowsNativeMethods.CredentialDat
 4823                return Marshal.PtrToStringAnsi(credData.CredentialBlob, (int) credData.CredentialBlobSize);
 24            }
 25            finally
 26            {
 4827                WindowsNativeMethods.CredFree(credentials);
 4828            }
 4829        }
 30    }
 31}