Skip to content

Commit 97a5c8a

Browse files
committed
misc: fix namespaces and minor things
1 parent 020cef2 commit 97a5c8a

File tree

29 files changed

+20
-63
lines changed

29 files changed

+20
-63
lines changed

.github/workflows/verify-code-style.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ on:
3030
jobs:
3131
verify-code-style:
3232
name: "Verify code style"
33-
runs-on: windows-2019
33+
runs-on: windows-latest
3434

3535
steps:
3636
- uses: actions/checkout@v4

Yubico.Core/src/Yubico/Core/Devices/Hid/WindowsHidDevice.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ private void ResolveIdsFromInstancePath(string instancePath)
7676
// 012345678901234567890123456789
7777
// ^--- ^---
7878

79-
#pragma warning disable CA1862
79+
// Disable string comparison warning for this method as it needs to compile for both net47, netstandard 2.0 and 2.1
80+
#pragma warning disable CA1862
8081
if (instancePath.ToUpperInvariant().Contains("VID") && instancePath.ToUpperInvariant().Contains("HID"))
8182
#pragma warning restore CA1862
8283
{

Yubico.Core/src/Yubico/PlatformInterop/Desktop/SCard/SCardReaderStates.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,24 @@ namespace Yubico.PlatformInterop
2323
{
2424
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
2525
// Justification: Fields are read/write via interop. Readonly might not have any effect there, but it may give
26-
// maintainers a falls impression about the true nature of these fields.
26+
// maintainers a false impression about the true nature of these fields.
2727
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")]
2828
[SuppressMessage("Style", "IDE0044:Add readonly modifier")]
2929
internal struct SCARD_READER_STATE
3030
{
31-
#pragma warning disable IDE0032
32-
[MarshalAs(UnmanagedType.LPStr)]
33-
private string _readerName;
34-
#pragma warning restore IDE0032
3531
private IntPtr _userData;
3632
private uint _currentState;
3733
private uint _eventState;
3834
private uint _atrLength;
35+
3936
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 36)]
4037
private byte[] _answerToReset;
4138

4239
private const uint SequenceMask = 0xFFFF_0000;
4340
private const uint StateMask = 0x0000_FFFF;
4441

45-
public string ReaderName
46-
{
47-
get => _readerName;
48-
set => _readerName = value;
49-
}
42+
[field: MarshalAs(UnmanagedType.LPStr)]
43+
public string ReaderName { get; set; }
5044

5145
public SCARD_STATE CurrentState => (SCARD_STATE)(_currentState & StateMask);
5246
public SCARD_STATE EventState => (SCARD_STATE)(_eventState & StateMask);

Yubico.YubiKey/examples/Fido2SampleCode/Fido2SampleCode.csproj

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,19 @@ distributed under the License is distributed on an "AS IS" BASIS,
1111
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License. -->
14-
<!-- <TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">$(TargetFrameworks);net6.0-windows</TargetFrameworks>
15-
-->
16-
<Project Sdk="Microsoft.NET.Sdk">
1714

15+
<Project Sdk="Microsoft.NET.Sdk">
1816
<PropertyGroup>
1917
<OutputType>Exe</OutputType>
20-
<TargetFramework>net9.0</TargetFramework>
21-
<Nullable>disable</Nullable>
18+
<TargetFramework>net9.0</TargetFramework>
19+
<Nullable>disable</Nullable>
2220
<IsPackable>false</IsPackable>
23-
<!--<UseWindowsForms Condition=" '$(OS)' == 'Windows_NT'">true</UseWindowsForms>-->
2421
<AnalysisMode>AllDisabledByDefault</AnalysisMode>
2522
</PropertyGroup>
2623
<ItemGroup>
27-
<None Update="appsettings.json">
28-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
29-
</None>
24+
<None Update="appsettings.json">
25+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
26+
</None>
3027
<ProjectReference Include="..\SharedSampleCode\SharedSampleCode.csproj" />
31-
3228
</ItemGroup>
33-
34-
3529
</Project>

Yubico.YubiKey/examples/OathSampleCode/YubiKeyOperations/AddCredential.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ public static bool RunAddCredentialFromQR(
193193

194194
private static void ReportResult(Credential credential)
195195
{
196-
#pragma warning disable CA1305
197196
var outputList = new StringBuilder("Added credential:");
198197
_ = outputList.AppendLine();
199198
_ = outputList.AppendLine($"Issuer : {credential.Issuer}");

Yubico.YubiKey/examples/OathSampleCode/YubiKeyOperations/CalculateCredentials.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414

1515
using System;
1616
using System.Collections.Generic;
17-
using System.Diagnostics.CodeAnalysis;
1817
using System.Text;
1918
using Yubico.YubiKey.Oath;
2019
using Yubico.YubiKey.Sample.SharedCode;
2120

2221
namespace Yubico.YubiKey.Sample.OathSampleCode
2322
{
24-
[SuppressMessage("Globalization", "CA1305:Specify IFormatProvider")]
2523
public static class CalculateCredentials
2624
{
2725
// Get OTP (One-Time Password) values for all configured credentials on the YubiKey.

Yubico.YubiKey/examples/OathSampleCode/YubiKeyOperations/GetCredentials.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414

1515
using System;
1616
using System.Collections.Generic;
17-
using System.Diagnostics.CodeAnalysis;
1817
using System.Text;
1918
using Yubico.YubiKey.Oath;
2019
using Yubico.YubiKey.Sample.SharedCode;
2120

2221
namespace Yubico.YubiKey.Sample.OathSampleCode
2322
{
24-
[SuppressMessage("Globalization", "CA1305:Specify IFormatProvider")]
2523
public static class GetCredentials
2624
{
2725
// Get all configured credentials on the YbiKey.

Yubico.YubiKey/examples/OathSampleCode/YubiKeyOperations/RemoveCredential.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
// limitations under the License.
1414

1515
using System;
16-
using System.Diagnostics.CodeAnalysis;
1716
using System.Text;
1817
using Yubico.YubiKey.Oath;
1918
using Yubico.YubiKey.Sample.SharedCode;
2019

2120
namespace Yubico.YubiKey.Sample.OathSampleCode
2221
{
23-
[SuppressMessage("Globalization", "CA1305:Specify IFormatProvider")]
2422
public static class RemoveCredential
2523
{
2624
// Remove an existing credential on the YubiKey.

Yubico.YubiKey/examples/OathSampleCode/YubiKeyOperations/RenameCredential.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
// limitations under the License.
1414

1515
using System;
16-
using System.Diagnostics.CodeAnalysis;
1716
using System.Text;
1817
using Yubico.YubiKey.Oath;
1918
using Yubico.YubiKey.Sample.SharedCode;
2019

2120
namespace Yubico.YubiKey.Sample.OathSampleCode
2221
{
23-
[SuppressMessage("Globalization", "CA1305:Specify IFormatProvider")]
2422
public static class RenameCredential
2523
{
2624
// Rename the existing credential on the YubiKey by setting new issuer and account names.

Yubico.YubiKey/examples/SharedSampleCode/SharedSampleCode.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ limitations under the License. -->
2525
</PropertyGroup>
2626

2727
<!--
28-
To test against local YubiKey library changes, uncomment the following line and adjust the path as needed.
29-
and comment out the PackageReference line that references the wildcard version (which is attained from NuGet).
28+
To test against local YubiKey library changes, uncomment the following line and adjust the path as needed
29+
and comment out the Yubico.YubiKey PackageReference line below that references the wildcard version (which would then be fetched from the NuGet servers).
3030
<ItemGroup>
3131
<ProjectReference Include="..\..\src\Yubico.YubiKey.csproj" />
3232
</ItemGroup>-->

0 commit comments

Comments
 (0)