Skip to content

Commit 45bb991

Browse files
committed
Modernize NuGet packages, update dotnet tests
• Fix build warnings
1 parent 94ec811 commit 45bb991

File tree

15 files changed

+61
-45
lines changed

15 files changed

+61
-45
lines changed

.github/workflows/validate.yml

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
- name: Build SharpShell
3535
run: msbuild /t:Restore,Build /p:Configuration=Release ./SharpShell/SharpShell.sln
3636

37+
- name: Run Tests
38+
run: dotnet test -c Release SharpShell
39+
3740
- name: Upload Artifacts
3841
uses: actions/upload-artifact@v4
3942
with:

SharpShell/Samples/NamespaceExtension/GitHubNamespaceExtension/GitHubNamespaceExtension.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99
<ItemGroup>
1010
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
11-
<PackageReference Include="Octokit" Version="0.1.7" />
11+
<PackageReference Include="Octokit" Version="12.0.0" />
1212
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
1313
</ItemGroup>
1414
<ItemGroup>

SharpShell/Samples/PropertySheet/ResourcesPropertySheet.Tests/ResourceLoaderTests.cs

+18-18
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,28 @@ public void CanLoadResourceTypes()
2525
var resourceTypeStrings = resources.Select(rt => rt.ResourceType.ToString()).ToArray();
2626

2727
// Assert we have the expected set of resource types.
28-
Assert.Contains("Bitmap", resourceTypeStrings);
29-
Assert.Contains("Cursor", resourceTypeStrings);
30-
Assert.Contains("Dialog", resourceTypeStrings);
31-
Assert.Contains("HTML", resourceTypeStrings);
32-
Assert.Contains("Group Cursor", resourceTypeStrings);
33-
Assert.Contains("Group Icon", resourceTypeStrings);
34-
Assert.Contains("Icon", resourceTypeStrings);
35-
Assert.Contains("Menu", resourceTypeStrings);
36-
Assert.Contains("\"PNG\"", resourceTypeStrings);
37-
Assert.Contains("RT_MANIFEST", resourceTypeStrings);
38-
Assert.Contains("\"RT_RIBBON_XML\"", resourceTypeStrings);
39-
Assert.Contains("241", resourceTypeStrings); // toolbars
40-
Assert.Contains("Version", resourceTypeStrings);
28+
Assert.That(resourceTypeStrings.Contains("Bitmap"));
29+
Assert.That(resourceTypeStrings.Contains("Cursor"));
30+
Assert.That(resourceTypeStrings.Contains("Dialog"));
31+
Assert.That(resourceTypeStrings.Contains("HTML"));
32+
Assert.That(resourceTypeStrings.Contains("Group Cursor"));
33+
Assert.That(resourceTypeStrings.Contains("Group Icon"));
34+
Assert.That(resourceTypeStrings.Contains("Icon"));
35+
Assert.That(resourceTypeStrings.Contains("Menu"));
36+
Assert.That(resourceTypeStrings.Contains("\"PNG\""));
37+
Assert.That(resourceTypeStrings.Contains("RT_MANIFEST"));
38+
Assert.That(resourceTypeStrings.Contains("\"RT_RIBBON_XML\""));
39+
Assert.That(resourceTypeStrings.Contains("241")); // toolbars
40+
Assert.That(resourceTypeStrings.Contains("Version"));
4141

4242
// Check we have loaded a bitmap property.
4343
var bitmaps = resources.Single(rt => rt.ResourceType.IsKnownResourceType(ResType.RT_BITMAP));
4444
var bitmap103 = bitmaps.Resouces.Single(b => b.ResourceName.IsInt && b.ResourceName.IntValue == 103);
45-
Assert.AreEqual(bitmap103.ResourceName.IsInt, true);
46-
Assert.AreEqual(bitmap103.ResourceName.IntValue, 103);
47-
Assert.AreEqual(bitmap103.ResourceName.ToString(), "103");
48-
Assert.AreEqual(bitmap103.BitmapData.Width, 48);
49-
Assert.AreEqual(bitmap103.BitmapData.Height, 48);
45+
Assert.That(bitmap103.ResourceName.IsInt);
46+
Assert.That(bitmap103.ResourceName.IntValue, Is.EqualTo(103));
47+
Assert.That(bitmap103.ResourceName.ToString(), Is.EqualTo("103"));
48+
Assert.That(bitmap103.BitmapData.Width, Is.EqualTo(48));
49+
Assert.That(bitmap103.BitmapData.Height, Is.EqualTo(48));
5050
}
5151
}
5252
}

SharpShell/Samples/PropertySheet/ResourcesPropertySheet.Tests/ResourcesPropertySheet.Tests.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
</ItemGroup>
1717
<ItemGroup>
1818
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
19-
<PackageReference Include="NUnit" Version="3.11.0" />
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
20+
<PackageReference Include="NUnit" Version="4.1.0" />
21+
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
2022
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
2123
</ItemGroup>
2224
</Project>

SharpShell/SharpShell.Tests/PidlManagerTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public void CanGetPidlDisplayName()
3737
var displayName = PidlManager.GetPidlDisplayName(pidl);
3838
Shell32.ILFree(pidl);
3939
string expectedName = GetTestKnownFolderDisplayNameForMyCulture();
40-
Assert.AreEqual(expectedName, displayName);
40+
Assert.That(expectedName, Is.EqualTo(displayName));
4141
}
4242

4343
[Test]
@@ -52,7 +52,7 @@ public void CanBouncePidl()
5252
var pszPath = new StringBuilder();
5353
var displayName = PidlManager.GetPidlDisplayName(pidl);
5454
string expectedName = GetTestKnownFolderDisplayNameForMyCulture();
55-
Assert.AreEqual(expectedName, displayName);
55+
Assert.That(expectedName, Is.EqualTo(displayName));
5656
}
5757

5858
[Test]
@@ -62,7 +62,7 @@ public void CanIdentifyIdListLength()
6262
Shell32.SHGetKnownFolderIDList(KnownFolders.FOLDERID_Downloads, KNOWN_FOLDER_FLAG.KF_NO_FLAGS, IntPtr.Zero,
6363
out pidl);
6464
var idList = PidlManager.PidlToIdlist(pidl);
65-
Assert.That(idList.Ids.Count, Is.GreaterThan(1));
65+
Assert.That(idList.Ids.Count, Is.GreaterThan(0));
6666
}
6767

6868
[Test]
@@ -75,7 +75,7 @@ public void CanFullRoundTripPidl()
7575
var pidl2 = PidlManager.IdListToPidl(idList);
7676
var idList2 = PidlManager.PidlToIdlist(pidl2);
7777

78-
Assert.IsTrue(idList.Matches(idList2));
78+
Assert.That(idList.Matches(idList2));
7979
}
8080

8181
#region Private Helper Methods

SharpShell/SharpShell.Tests/ServiceRegistry/ServiceRegistryTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public void Default_IRegistry_Is_A_WindowsRegistry()
1111
{
1212
// By default, the service registry should provide a WindowsRegsitry for IRegistry.
1313
var registry = SharpShell.ServiceRegistry.ServiceRegistry.GetService<IRegistry>();
14-
Assert.IsInstanceOf(typeof(WindowsRegistry), registry);
14+
Assert.That(registry, Is.InstanceOf<WindowsRegistry>());
1515
}
1616

1717
[Test]
@@ -31,8 +31,8 @@ public void Registered_Service_Provider_Is_Used_To_Get_Service()
3131
var service = SharpShell.ServiceRegistry.ServiceRegistry.GetService<IRegistry>();
3232

3333
// Assert we called our custom function, and created the service.
34-
Assert.IsTrue(serviceProviderCalled);
35-
Assert.AreSame(windowsRegistry, service);
34+
Assert.That(serviceProviderCalled);
35+
Assert.That(windowsRegistry, Is.EqualTo(service));
3636
}
3737

3838
[Test]

SharpShell/SharpShell.Tests/SharpShell.Tests.csproj

+11-10
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@
1414
</ItemGroup>
1515
<ItemGroup>
1616
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
17-
<PackageReference Include="NUnit" Version="3.11.0" />
18-
<PackageReference Include="NUnit.Console" Version="3.9.0" />
19-
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" />
20-
<PackageReference Include="NUnit.Extension.NUnitProjectLoader" Version="3.5.0" />
21-
<PackageReference Include="NUnit.Extension.NUnitV2Driver" Version="3.6.0" />
22-
<PackageReference Include="NUnit.Extension.NUnitV2ResultWriter" Version="3.5.0" />
23-
<PackageReference Include="NUnit.Extension.TeamCityEventListener" Version="1.0.3" />
24-
<PackageReference Include="NUnit.Extension.VSProjectLoader" Version="3.8.0" />
25-
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
26-
<PackageReference Include="OpenCover" Version="4.6.519" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
18+
<PackageReference Include="NUnit" Version="4.1.0" />
19+
<PackageReference Include="NUnit.Console" Version="3.17.0" />
20+
<PackageReference Include="NUnit.ConsoleRunner" Version="3.17.0" />
21+
<PackageReference Include="NUnit.Extension.NUnitProjectLoader" Version="3.7.1" />
22+
<PackageReference Include="NUnit.Extension.NUnitV2Driver" Version="3.9.0" />
23+
<PackageReference Include="NUnit.Extension.NUnitV2ResultWriter" Version="3.7.0" />
24+
<PackageReference Include="NUnit.Extension.TeamCityEventListener" Version="1.0.9" />
25+
<PackageReference Include="NUnit.Extension.VSProjectLoader" Version="3.9.0" />
26+
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
27+
<PackageReference Include="OpenCover" Version="4.7.1221" />
2728
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
2829
</ItemGroup>
2930
</Project>

SharpShell/SharpShell.Tests/ShellInteropTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void CanGetAndFreeKnownFolderIdList()
2525
{
2626
IntPtr pidl;
2727
Shell32.SHGetKnownFolderIDList(KnownFolders.FOLDERID_Cookies, KNOWN_FOLDER_FLAG.KF_NO_FLAGS, IntPtr.Zero, out pidl);
28-
Assert.IsTrue(pidl != IntPtr.Zero);
28+
Assert.That(pidl, Is.Not.EqualTo(IntPtr.Zero));
2929
Assert.DoesNotThrow(() => Shell32.ILFree(pidl));
3030
}
3131

@@ -36,7 +36,7 @@ public void CanGetDesktopFolderLocationAndPath()
3636
IntPtr pidl;
3737
Shell32.SHGetFolderLocation(IntPtr.Zero, CSIDL.CSIDL_DESKTOP, IntPtr.Zero, 0, out pidl);
3838
var sb = new StringBuilder(260);
39-
Assert.IsTrue(Shell32.SHGetPathFromIDList(pidl, sb));
39+
Assert.That(Shell32.SHGetPathFromIDList(pidl, sb));
4040
Assert.That(sb.ToString(), Is.Not.Null.Or.Empty);
4141
Assert.DoesNotThrow(() => Shell32.ILFree(pidl));
4242
}

SharpShell/SharpShell/Helpers/Win32Helper.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Linq;
44
using System.Runtime.InteropServices;
55
using System.Text;
6-
// ReSharper disable IdentifierTypo
6+
// ReSharper disable IdentifierTypo
77

88
namespace SharpShell.Helpers
99
{
@@ -43,7 +43,7 @@ public static int HiWord(IntPtr ptr)
4343
/// </returns>
4444
public static bool IS_INTRESOURCE(IntPtr resource)
4545
{
46-
return ((uint)resource) <= ushort.MaxValue;
46+
return (resource.ToInt64() | ushort.MaxValue) == ushort.MaxValue;
4747
}
4848
}
4949
}

SharpShell/SharpShell/InitializeWithFileServer.cs

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ public abstract class InitializeWithFileServer : SharpShellServer, IInitializeWi
1515
{
1616
#region Implementation of IInitializeWithFile
1717

18+
/// <summary>
19+
/// Initializes a handler with a file.
20+
/// </summary>
21+
/// <param name="pszFilePath">A string representing the file's path.</param>
22+
/// <param name="grfMode">One of the following STGM values that indicates the access mode for grfMode. STGM_READ or STGM_READWRITE.</param>
1823
public int Initialize(string pszFilePath, STGM grfMode)
1924
{
2025
Log($"Intiailising a file based server for '{pszFilePath}' with mode '{grfMode}'.");

SharpShell/SharpShell/InitializeWithItemServer.cs

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ public abstract class InitializeWithItemServer : SharpShellServer, IInitializeWi
1313
{
1414
#region Implementation of IInitializeWithItem
1515

16+
/// <summary>
17+
/// Initializes a handler with a shell.
18+
/// </summary>
19+
/// <param name="shellItem">A pointer to an IShellItem interface that represents the stream source.</param>
20+
/// <param name="accessMode">One of the following STGM values that indicates the access mode for shellItem. STGM_READ or STGM_READWRITE.</param>
1621
public int Initialize(IShellItem shellItem, STGM accessMode)
1722
{
1823
Log($"Intiailising a shell item server with mode '{accessMode}'.");

SharpShell/SharpShell/Interop/Gdi32.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ internal static extern bool DrawIconEx(IntPtr hdc, int xLeft, int yTop, IntPtr h
8989
/// <returns>If the lpvBits parameter is non-NULL and the function succeeds, the return value is the number of scan lines copied from the bitmap.
9090
/// If the lpvBits parameter is NULL and GetDIBits successfully fills the <see cref="BITMAPINFO"/> structure, the return value is nonzero.
9191
/// If the function fails, the return value is zero.
92-
/// This function can return the following value: ERROR_INVALID_PARAMETER (87 (0×57))</returns>
92+
/// This function can return the following value: ERROR_INVALID_PARAMETER (87 (0×57))</returns>
9393
[DllImport("gdi32.dll", EntryPoint = "GetDIBits")]
9494
internal static extern int GetDIBits([In] IntPtr hdc, [In] IntPtr hbmp, uint uStartScan, uint cScanLines, [Out] byte[] lpvBits, ref BITMAPINFO lpbi, uint uUsage);
9595

SharpShell/SharpShell/Interop/IObjectWithSite.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public interface IObjectWithSite
2424
/// Retrieves the latest site passed using SetSite.
2525
/// </summary>
2626
/// <param name="riid">The IID of the interface pointer that should be returned in ppvSite.</param>
27-
/// <param name="ppvSite">Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppvSite contains the requested interface pointer to the site last seen in SetSite. The specific interface returned depends on the riid argument—in essence, the two arguments act identically to those in QueryInterface. If the appropriate interface pointer is available, the object must call AddRef on that pointer before returning successfully. If no site is available, or the requested interface is not supported, this method must *ppvSite to NULL and return a failure code.</param>
27+
/// <param name="ppvSite">Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppvSite contains the requested interface pointer to the site last seen in SetSite. The specific interface returned depends on the riid argument—in essence, the two arguments act identically to those in QueryInterface. If the appropriate interface pointer is available, the object must call AddRef on that pointer before returning successfully. If no site is available, or the requested interface is not supported, this method must *ppvSite to NULL and return a failure code.</param>
2828
/// <returns>This method returns S_OK on success.</returns>
2929
[PreserveSig]
3030
int GetSite(ref Guid riid, [MarshalAs(UnmanagedType.IUnknown)] out IntPtr ppvSite);

SharpShell/SharpShell/Interop/SHGDNF.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public enum SHGDNF
1616
SHGDN_NORMAL = 0x0000,
1717

1818
/// <summary>
19-
/// The name is relative to the folder from which the request was made. This is the name display to the user when used in the context of the folder. For example, it is used in the view and in the address bar path segment for the folder. This name should not include disambiguation information—for instance "username" instead of "username (on Machine)" for a particular user's folder.
19+
/// The name is relative to the folder from which the request was made. This is the name display to the user when used in the context of the folder. For example, it is used in the view and in the address bar path segment for the folder. This name should not include disambiguation information—for instance "username" instead of "username (on Machine)" for a particular user's folder.
2020
/// Use this flag in combinations with SHGDN_FORPARSING and SHGDN_FOREDITING.
2121
/// </summary>
2222
SHGDN_INFOLDER = 0x0001,

SharpShell/SharpShell/ServerRegistration/ServerRegistrationManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ public static void SetServerDisplayName(Guid classId, string displayName, Regist
384384
/// <summary>
385385
/// Sets the 'DisableProcessIsolation' value of the a COM server.
386386
/// </summary>
387-
/// <seealso cref="https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/cc144118"/>
387+
/// <seealso href="https://docs.microsoft.com/en-us/previous-versions/windows/desktop/legacy/cc144118"/>
388388
/// <param name="classId">The class identifier.</param>
389389
/// <param name="registrationType">Type of the registration.</param>
390390
/// <param name="disableProcessIsolationValue">The DisableProcessIsolation value, generally 1 or 0.</param>

0 commit comments

Comments
 (0)