Skip to content

Commit

Permalink
Delete dead code (#19208)
Browse files Browse the repository at this point in the history
- IsAppXDesignMode is always false
- Win32Res class is never used
  • Loading branch information
jkotas authored Jul 31, 2018
1 parent d4f533b commit c62976e
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 1,055 deletions.
16 changes: 0 additions & 16 deletions src/System.Private.CoreLib/src/System/AppDomain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ private enum APPX_FLAGS
APPX_FLAGS_INITIALIZED = 0x01,

APPX_FLAGS_APPX_MODEL = 0x02,
APPX_FLAGS_APPX_DESIGN_MODE = 0x04,
APPX_FLAGS_APPX_MASK = APPX_FLAGS_APPX_MODEL |
APPX_FLAGS_APPX_DESIGN_MODE,
}

private static APPX_FLAGS Flags
Expand Down Expand Up @@ -204,19 +201,6 @@ internal static bool IsAppXModel()
#endif
}

/// <summary>
/// Returns the setting of the AppXDevMode config switch.
/// </summary>
[Pure]
internal static bool IsAppXDesignMode()
{
#if FEATURE_APPX
return (Flags & APPX_FLAGS.APPX_FLAGS_APPX_MASK) == (APPX_FLAGS.APPX_FLAGS_APPX_MODEL | APPX_FLAGS.APPX_FLAGS_APPX_DESIGN_MODE);
#else
return false;
#endif
}

/// <summary>
/// Checks (and throws on failure) if the domain supports Assembly.LoadFrom.
/// </summary>
Expand Down
126 changes: 47 additions & 79 deletions src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -838,26 +838,6 @@ private void SetAppXConfiguration()
if (reswFilename == null)
reswFilename = string.Empty;

WindowsRuntimeResourceManagerBase WRRM = null;
bool bWRRM_Initialized = false;

if (AppDomain.IsAppXDesignMode())
{
WRRM = GetWinRTResourceManager();
try
{
PRIExceptionInfo exceptionInfo; // If the exception info is filled in, we will ignore it.
bWRRM_Initialized = WRRM.Initialize(resourcesAssembly.Location, reswFilename, out exceptionInfo);
bUsingSatelliteAssembliesUnderAppX = !bWRRM_Initialized;
}
catch (Exception e)
{
bUsingSatelliteAssembliesUnderAppX = true;
if (e.IsTransient)
throw;
}
}

if (!bUsingSatelliteAssembliesUnderAppX)
{
_bUsingModernResourceManagement = !ShouldUseSatelliteAssemblyResourceLookupUnderAppX(resourcesAssembly);
Expand All @@ -866,9 +846,6 @@ private void SetAppXConfiguration()
{
// Only now are we certain that we need the PRI file.

// Note that if IsAppXDesignMode is false, we haven't checked if the PRI file exists.
// This is by design. We will find out in the call to WindowsRuntimeResourceManager.Initialize below.

// At this point it is important NOT to set _bUsingModernResourceManagement to false
// if the PRI file does not exist because we are now certain we need to load PRI
// resources. We want to fail by throwing a MissingManifestResourceException
Expand All @@ -877,66 +854,57 @@ private void SetAppXConfiguration()
// the MissingManifestResourceException from this function, but from GetString. See the
// comment below on the reason for this.

if (WRRM != null && bWRRM_Initialized)
_WinRTResourceManager = GetWinRTResourceManager();

try
{
// Reuse the one successfully created earlier
_WinRTResourceManager = WRRM;
_PRIonAppXInitialized = true;
_PRIonAppXInitialized = _WinRTResourceManager.Initialize(resourcesAssembly.Location, reswFilename, out _PRIExceptionInfo);
// Note that _PRIExceptionInfo might be null - this is OK.
// In that case we will just throw the generic
// MissingManifestResource_NoPRIresources exception.
// See the implementation of GetString for more details.
}
else
// We would like to be able to throw a MissingManifestResourceException here if PRI resources
// could not be loaded for a recognized reason. However, the ResourceManager constructors
// that call SetAppXConfiguration are not documented as throwing MissingManifestResourceException,
// and since they are part of the portable profile, we cannot start throwing a new exception type
// as that would break existing portable libraries. Hence we must save the exception information
// now and throw the exception on the first call to GetString.
catch (FileNotFoundException)
{
_WinRTResourceManager = GetWinRTResourceManager();

try
{
_PRIonAppXInitialized = _WinRTResourceManager.Initialize(resourcesAssembly.Location, reswFilename, out _PRIExceptionInfo);
// Note that _PRIExceptionInfo might be null - this is OK.
// In that case we will just throw the generic
// MissingManifestResource_NoPRIresources exception.
// See the implementation of GetString for more details.
}
// We would like to be able to throw a MissingManifestResourceException here if PRI resources
// could not be loaded for a recognized reason. However, the ResourceManager constructors
// that call SetAppXConfiguration are not documented as throwing MissingManifestResourceException,
// and since they are part of the portable profile, we cannot start throwing a new exception type
// as that would break existing portable libraries. Hence we must save the exception information
// now and throw the exception on the first call to GetString.
catch (FileNotFoundException)
{
// We will throw MissingManifestResource_NoPRIresources from GetString
// when we see that _PRIonAppXInitialized is false.
}
catch (Exception e)
{
// ERROR_MRM_MAP_NOT_FOUND can be thrown by the call to ResourceManager.get_AllResourceMaps
// in WindowsRuntimeResourceManager.Initialize.
// In this case _PRIExceptionInfo is now null and we will just throw the generic
// MissingManifestResource_NoPRIresources exception.
// See the implementation of GetString for more details.
if (e.HResult != HResults.ERROR_MRM_MAP_NOT_FOUND)
throw; // Unexpected exception code. Bubble it up to the caller.
}

if (!_PRIonAppXInitialized)
{
_bUsingModernResourceManagement = false;
}
// Allow all other exception types to bubble up to the caller.

// Yes, this causes us to potentially throw exception types that are not documented.

// Ultimately the tradeoff is the following:
// -We could ignore unknown exceptions or rethrow them as inner exceptions
// of exceptions that the ResourceManager class is already documented as throwing.
// This would allow existing portable libraries to gracefully recover if they don't care
// too much about the ResourceManager object they are using. However it could
// mask potentially fatal errors that we are not aware of, such as a disk drive failing.


// The alternative, which we chose, is to throw unknown exceptions. This may tear
// down the process if the portable library and app don't expect this exception type.
// On the other hand, this won't mask potentially fatal errors we don't know about.
// We will throw MissingManifestResource_NoPRIresources from GetString
// when we see that _PRIonAppXInitialized is false.
}
catch (Exception e)
{
// ERROR_MRM_MAP_NOT_FOUND can be thrown by the call to ResourceManager.get_AllResourceMaps
// in WindowsRuntimeResourceManager.Initialize.
// In this case _PRIExceptionInfo is now null and we will just throw the generic
// MissingManifestResource_NoPRIresources exception.
// See the implementation of GetString for more details.
if (e.HResult != HResults.ERROR_MRM_MAP_NOT_FOUND)
throw; // Unexpected exception code. Bubble it up to the caller.
}

if (!_PRIonAppXInitialized)
{
_bUsingModernResourceManagement = false;
}
// Allow all other exception types to bubble up to the caller.

// Yes, this causes us to potentially throw exception types that are not documented.

// Ultimately the tradeoff is the following:
// -We could ignore unknown exceptions or rethrow them as inner exceptions
// of exceptions that the ResourceManager class is already documented as throwing.
// This would allow existing portable libraries to gracefully recover if they don't care
// too much about the ResourceManager object they are using. However it could
// mask potentially fatal errors that we are not aware of, such as a disk drive failing.


// The alternative, which we chose, is to throw unknown exceptions. This may tear
// down the process if the portable library and app don't expect this exception type.
// On the other hand, this won't mask potentially fatal errors we don't know about.
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,6 @@ set(VM_SOURCES_DAC_AND_WKS_WIN32
list(APPEND VM_SOURCES_WKS
${VM_SOURCES_DAC_AND_WKS_WIN32}
# These should not be included for Linux
appxutil.cpp
assemblynativeresource.cpp
classcompat.cpp
classfactory.cpp
clrprivbinderwinrt.cpp
Expand Down
6 changes: 0 additions & 6 deletions src/vm/appdomainnative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ enum
APPX_FLAGS_INITIALIZED = 0x01,

APPX_FLAGS_APPX_MODEL = 0x02,
APPX_FLAGS_APPX_DESIGN_MODE = 0x04,
APPX_FLAGS_APPX_MASK = APPX_FLAGS_APPX_MODEL |
APPX_FLAGS_APPX_DESIGN_MODE,
};

// static
Expand All @@ -220,9 +217,6 @@ INT32 QCALLTYPE AppDomainNative::GetAppXFlags()
if (AppX::IsAppXProcess())
{
flags |= APPX_FLAGS_APPX_MODEL;

if (AppX::IsAppXDesignMode())
flags |= APPX_FLAGS_APPX_DESIGN_MODE;
}

END_QCALL;
Expand Down
Loading

0 comments on commit c62976e

Please sign in to comment.