Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,9 @@ public static partial class Activator
}
else
{
RuntimeAssembly? assemblyFromResolveEvent;
AssemblyName assemblyName = RuntimeAssembly.CreateAssemblyName(assemblyString, out assemblyFromResolveEvent);
if (assemblyFromResolveEvent != null)
{
// Assembly was resolved via AssemblyResolve event
assembly = assemblyFromResolveEvent;
}
else if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime)
AssemblyName assemblyName = new AssemblyName(assemblyString);

if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime)
{
// WinRT type - we have to use Type.GetType
type = Type.GetType(typeName + ", " + assemblyString, true /*throwOnError*/, ignoreCase);
Expand Down
19 changes: 0 additions & 19 deletions src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,25 +199,6 @@ public static Assembly GetAssembly(Type type)

public static Assembly Load(byte[] rawAssembly) => Load(rawAssembly, rawSymbolStore: null);

[Obsolete("This method has been deprecated. Please use Assembly.Load() instead. https://go.microsoft.com/fwlink/?linkid=14202")]
public static Assembly LoadWithPartialName(string partialName)
{
if (partialName == null)
throw new ArgumentNullException(nameof(partialName));

if ((partialName.Length == 0) || (partialName[0] == '\0'))
throw new ArgumentException(SR.Format_StringZeroLength, nameof(partialName));

try
{
return Load(partialName);
}
catch (FileNotFoundException)
{
return null;
}
}

// Loads the assembly with a COFF based IMAGE containing
// an emitted assembly. The assembly is loaded into a fully isolated ALC with resolution fully deferred to the AssemblyLoadContext.Default.
// The second parameter is the raw bytes representing the symbol store that matches the assembly.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

#nullable enable
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
Expand All @@ -22,6 +23,27 @@ public static Assembly Load(string assemblyString)
return RuntimeAssembly.InternalLoad(assemblyString, ref stackMark, AssemblyLoadContext.CurrentContextualReflectionContext);
}

[Obsolete("This method has been deprecated. Please use Assembly.Load() instead. https://go.microsoft.com/fwlink/?linkid=14202")]
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
public static Assembly? LoadWithPartialName(string partialName)
{
if (partialName == null)
throw new ArgumentNullException(nameof(partialName));

if ((partialName.Length == 0) || (partialName[0] == '\0'))
throw new ArgumentException(SR.Format_StringZeroLength, nameof(partialName));

try
{
StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
return RuntimeAssembly.InternalLoad(partialName, ref stackMark, AssemblyLoadContext.CurrentContextualReflectionContext);
}
catch (FileNotFoundException)
{
return null;
}
}

// Locate an assembly by its name. The name can be strong or
// weak. The assembly is loaded into the domain of the caller.
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public AssemblyName(string assemblyName)
throw new ArgumentException(SR.Format_StringZeroLength);

_name = assemblyName;
nInit(out RuntimeAssembly? dummy, false);
nInit();
}

internal AssemblyName(string? name,
Expand All @@ -49,7 +49,7 @@ internal AssemblyName(string? name,
}

[MethodImpl(MethodImplOptions.InternalCall)]
internal extern void nInit(out RuntimeAssembly? assembly, bool raiseResolveEvent);
internal extern void nInit();

// This call opens and closes the file, but does not add the
// assembly to the domain.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,38 +306,11 @@ public override IList<CustomAttributeData> GetCustomAttributesData()

internal static RuntimeAssembly InternalLoad(string assemblyString, ref StackCrawlMark stackMark, AssemblyLoadContext? assemblyLoadContext = null)
{
RuntimeAssembly? assembly;
AssemblyName an = CreateAssemblyName(assemblyString, out assembly);

if (assembly != null)
{
// The assembly was returned from ResolveAssemblyEvent
return assembly;
}
AssemblyName an = new AssemblyName(assemblyString);

return InternalLoadAssemblyName(an, ref stackMark, assemblyLoadContext);
}

// Creates AssemblyName. Fills assembly if AssemblyResolve event has been raised.
internal static AssemblyName CreateAssemblyName(
string assemblyString,
out RuntimeAssembly? assemblyFromResolveEvent)
{
if (assemblyString == null)
throw new ArgumentNullException(nameof(assemblyString));

if ((assemblyString.Length == 0) ||
(assemblyString[0] == '\0'))
throw new ArgumentException(SR.Format_StringZeroLength);

AssemblyName an = new AssemblyName();

an.Name = assemblyString;
an.nInit(out assemblyFromResolveEvent, true);

return an;
}

internal static RuntimeAssembly InternalLoadAssemblyName(AssemblyName assemblyRef, ref StackCrawlMark stackMark, AssemblyLoadContext? assemblyLoadContext = null)
{
#if FEATURE_APPX
Expand Down
17 changes: 1 addition & 16 deletions src/vm/assemblyname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ FCIMPL1(Object*, AssemblyNameNative::GetPublicKeyToken, Object* refThisUNSAFE)
FCIMPLEND


FCIMPL3(void, AssemblyNameNative::Init, Object * refThisUNSAFE, OBJECTREF * pAssemblyRef, CLR_BOOL fRaiseResolveEvent)
FCIMPL1(void, AssemblyNameNative::Init, Object * refThisUNSAFE)
{
FCALL_CONTRACT;

Expand All @@ -158,8 +158,6 @@ FCIMPL3(void, AssemblyNameNative::Init, Object * refThisUNSAFE, OBJECTREF * pAss

HELPER_METHOD_FRAME_BEGIN_1(pThis);

*pAssemblyRef = NULL;

if (pThis == NULL)
COMPlusThrow(kNullReferenceException, W("NullReference_This"));

Expand All @@ -174,19 +172,6 @@ FCIMPL3(void, AssemblyNameNative::Init, Object * refThisUNSAFE, OBJECTREF * pAss
{
spec.AssemblyNameInit(&pThis,NULL);
}
else if ((hr == FUSION_E_INVALID_NAME) && fRaiseResolveEvent)
{
Assembly * pAssembly = GetAppDomain()->RaiseAssemblyResolveEvent(&spec);

if (pAssembly == NULL)
{
EEFileLoadException::Throw(&spec, hr);
}
else
{
*((OBJECTREF *) (&(*pAssemblyRef))) = pAssembly->GetExposedObject();
}
}
else
{
ThrowHR(hr);
Expand Down
2 changes: 1 addition & 1 deletion src/vm/assemblyname.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AssemblyNameNative
static FCDECL1(Object*, ToString, Object* refThisUNSAFE);
static FCDECL1(Object*, GetPublicKeyToken, Object* refThisUNSAFE);
static FCDECL1(Object*, EscapeCodeBase, StringObject* filenameUNSAFE);
static FCDECL3(void, Init, Object * refThisUNSAFE, OBJECTREF * pAssemblyRef, CLR_BOOL fRaiseResolveEvent);
static FCDECL1(void, Init, Object * refThisUNSAFE);
};

#endif // _AssemblyName_H
Expand Down
4 changes: 4 additions & 0 deletions tests/CoreFX/CoreFX.issues.json
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,10 @@
"name": "System.Tests.VersionTests.Comparisons_NullArgument_ThrowsArgumentNullException",
"reason": "Version was improved to no longer throw from comparison operators"
},
{
"name" : "System.Tests.ActivatorNetcoreTests.CreateInstanceAssemblyResolve",
"reason" : "Waiting for https://github.com/dotnet/corefx/pull/37080"
}
]
}
},
Expand Down