Skip to content

Commit 04e9bc3

Browse files
authored
Remove ResourceUpdater.IsSupportedOS from HostModel (#103327)
`ResourceUpdater.IsSupportedOS` always returns `true` now - remove that API and the exceptions that were thrown when it wasn't supported. All uses of these APIs in dotnet/sdk have already been removed.
1 parent 1ddfd18 commit 04e9bc3

File tree

6 files changed

+3
-125
lines changed

6 files changed

+3
-125
lines changed

src/installer/managed/Microsoft.NET.HostModel/AppHost/AppHostExceptions.cs

-11
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@ internal AppHostUpdateException(string message = null)
1717
}
1818
}
1919

20-
/// <summary>
21-
/// The application host executable cannot be customized because adding resources requires
22-
/// that the build be performed on Windows (excluding Nano Server).
23-
/// </summary>
24-
public sealed class AppHostCustomizationUnsupportedOSException : AppHostUpdateException
25-
{
26-
internal AppHostCustomizationUnsupportedOSException()
27-
{
28-
}
29-
}
30-
3120
/// <summary>
3221
/// The MachO application host executable cannot be customized because
3322
/// it was not in the expected format

src/installer/managed/Microsoft.NET.HostModel/AppHost/HResultException.cs

-22
This file was deleted.

src/installer/managed/Microsoft.NET.HostModel/AppHost/RetryUtil.cs

-59
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33

44
using System;
55
using System.IO;
6-
using System.IO.MemoryMappedFiles;
7-
using System.Text;
86
using System.Threading;
97

108
namespace Microsoft.NET.HostModel
@@ -16,7 +14,6 @@ namespace Microsoft.NET.HostModel
1614
/// causing the operations to fail with IO-Error.
1715
/// So, the operations are retried a few times on failures such as
1816
/// - IOException
19-
/// - Failure with Win32 errors indicating file-lock
2017
/// </summary>
2118
public static class RetryUtil
2219
{
@@ -38,61 +35,5 @@ public static void RetryOnIOError(Action func)
3835
}
3936
}
4037
}
41-
42-
public static void RetryOnWin32Error(Action func)
43-
{
44-
static bool IsKnownIrrecoverableError(int hresult)
45-
{
46-
// Error codes are defined in winerror.h
47-
// The error code is stored in the lowest 16 bits of the HResult
48-
49-
switch (hresult & 0xffff)
50-
{
51-
case 0x00000001: // ERROR_INVALID_FUNCTION
52-
case 0x00000002: // ERROR_FILE_NOT_FOUND
53-
case 0x00000003: // ERROR_PATH_NOT_FOUND
54-
case 0x00000006: // ERROR_INVALID_HANDLE
55-
case 0x00000008: // ERROR_NOT_ENOUGH_MEMORY
56-
case 0x0000000B: // ERROR_BAD_FORMAT
57-
case 0x0000000E: // ERROR_OUTOFMEMORY
58-
case 0x0000000F: // ERROR_INVALID_DRIVE
59-
case 0x00000012: // ERROR_NO_MORE_FILES
60-
case 0x00000035: // ERROR_BAD_NETPATH
61-
case 0x00000057: // ERROR_INVALID_PARAMETER
62-
case 0x00000071: // ERROR_NO_MORE_SEARCH_HANDLES
63-
case 0x00000072: // ERROR_INVALID_TARGET_HANDLE
64-
case 0x00000078: // ERROR_CALL_NOT_IMPLEMENTED
65-
case 0x0000007B: // ERROR_INVALID_NAME
66-
case 0x0000007C: // ERROR_INVALID_LEVEL
67-
case 0x0000007D: // ERROR_NO_VOLUME_LABEL
68-
case 0x0000009A: // ERROR_LABEL_TOO_LONG
69-
case 0x000000A0: // ERROR_BAD_ARGUMENTS
70-
case 0x000000A1: // ERROR_BAD_PATHNAME
71-
case 0x000000CE: // ERROR_FILENAME_EXCED_RANGE
72-
case 0x000000DF: // ERROR_FILE_TOO_LARGE
73-
case 0x000003ED: // ERROR_UNRECOGNIZED_VOLUME
74-
case 0x000003EE: // ERROR_FILE_INVALID
75-
case 0x00000651: // ERROR_DEVICE_REMOVED
76-
return true;
77-
78-
default:
79-
return false;
80-
}
81-
}
82-
83-
for (int i = 1; i <= NumberOfRetries; i++)
84-
{
85-
try
86-
{
87-
func();
88-
break;
89-
}
90-
catch (HResultException hrex)
91-
when (i < NumberOfRetries && !IsKnownIrrecoverableError(hrex.Win32HResult))
92-
{
93-
Thread.Sleep(NumMilliSecondsToWait);
94-
}
95-
}
96-
}
9738
}
9839
}

src/installer/managed/Microsoft.NET.HostModel/ComHost/ComHost.cs

+3-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7-
using System.Runtime.InteropServices;
87
using System.Text;
98

109
namespace Microsoft.NET.HostModel.ComHost
@@ -18,10 +17,10 @@ public class ComHost
1817
/// <summary>
1918
/// Create a ComHost with an embedded CLSIDMap file to map CLSIDs to .NET Classes.
2019
/// </summary>
21-
/// <param name="comHostSourceFilePath">The path of Apphost template, which has the place holder</param>
20+
/// <param name="comHostSourceFilePath">The path of the comhost library</param>
2221
/// <param name="comHostDestinationFilePath">The destination path for desired location to place, including the file name</param>
2322
/// <param name="clsidmapFilePath">The path to the *.clsidmap file.</param>
24-
/// <param name="typeLibraries">Resource ids for tlbs and paths to the tlb files to be embedded.</param>
23+
/// <param name="typeLibraries">Resource IDs for tlbs and paths to the tlb files to be embedded.</param>
2524
public static void Create(
2625
string comHostSourceFilePath,
2726
string comHostDestinationFilePath,
@@ -34,14 +33,9 @@ public static void Create(
3433
Directory.CreateDirectory(destinationDirectory);
3534
}
3635

37-
// Copy apphost to destination path so it inherits the same attributes/permissions.
36+
// Copy comhost to destination path so it inherits the same attributes/permissions.
3837
File.Copy(comHostSourceFilePath, comHostDestinationFilePath, overwrite: true);
3938

40-
if (!ResourceUpdater.IsSupportedOS())
41-
{
42-
throw new ComHostCustomizationUnsupportedOSException();
43-
}
44-
4539
string clsidMap = File.ReadAllText(clsidmapFilePath);
4640
byte[] clsidMapBytes = Encoding.UTF8.GetBytes(clsidMap);
4741

src/installer/managed/Microsoft.NET.HostModel/ComHost/ComHostCustomizationUnsupportedOSException.cs

-15
This file was deleted.

src/installer/managed/Microsoft.NET.HostModel/ResourceUpdater.cs

-9
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ public class ResourceUpdater : IDisposable
2020
private ResourceData _resourceData;
2121
private readonly bool leaveOpen;
2222

23-
///<summary>
24-
/// Determines if the ResourceUpdater is supported by the current operating system.
25-
/// Some versions of Windows, such as Nano Server, do not support the needed APIs.
26-
/// </summary>
27-
public static bool IsSupportedOS()
28-
{
29-
return true;
30-
}
31-
3223
/// <summary>
3324
/// Create a resource updater for the given PE file.
3425
/// Resources can be added to this updater, which will queue them for update.

0 commit comments

Comments
 (0)