Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete unmanaged AssemblyName parser #68737

Merged
merged 2 commits into from
May 3, 2022
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 @@ -3,9 +3,8 @@

using System.Configuration.Assemblies;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.InteropServices;

namespace System.Reflection
{
Expand Down Expand Up @@ -61,7 +60,7 @@ public void SetVersion(Version? version, ushort defaultValue)
}
}

public sealed partial class AssemblyName : ICloneable, IDeserializationCallback, ISerializable
public sealed partial class AssemblyName
{
internal unsafe AssemblyName(NativeAssemblyNameParts* pParts)
: this()
Expand Down Expand Up @@ -149,5 +148,31 @@ private static ProcessorArchitecture CalculateProcArchIndex(PortableExecutableKi
}
return ProcessorArchitecture.None;
}

private static unsafe void ParseAsAssemblySpec(char* pAssemblyName, void* pAssemblySpec)
{
AssemblyNameParser.AssemblyNameParts parts = AssemblyNameParser.Parse(MemoryMarshal.CreateReadOnlySpanFromNullTerminated(pAssemblyName));

fixed (char* pName = parts._name)
fixed (char* pCultureName = parts._cultureName)
fixed (byte* pPublicKeyOrToken = parts._publicKeyOrToken)
{
NativeAssemblyNameParts nameParts = default;

nameParts._flags = parts._flags;
nameParts._pName = pName;
nameParts._pCultureName = pCultureName;

nameParts._pPublicKeyOrToken = pPublicKeyOrToken;
nameParts._cbPublicKeyOrToken = (parts._publicKeyOrToken != null) ? parts._publicKeyOrToken.Length : 0;

nameParts.SetVersion(parts._version, defaultValue: ushort.MaxValue);

InitializeAssemblySpec(&nameParts, pAssemblySpec);
}
}

[LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyName_InitializeAssemblySpec")]
private static unsafe partial void InitializeAssemblySpec(NativeAssemblyNameParts* pAssemblyNameParts, void* pAssemblySpec);
}
}
5 changes: 0 additions & 5 deletions src/coreclr/binder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ set(BINDER_COMMON_SOURCES
applicationcontext.cpp
assembly.cpp
assemblybindercommon.cpp
assemblyidentitycache.cpp
assemblyname.cpp
bindertracing.cpp
defaultassemblybinder.cpp
failurecache.cpp
stringlexer.cpp
textualidentityparser.cpp
utils.cpp
)
Expand All @@ -26,7 +24,6 @@ set(BINDER_COMMON_HEADERS
inc/assemblyentry.hpp
inc/assemblyhashtraits.hpp
inc/assemblyidentity.hpp
inc/assemblyidentitycache.hpp
inc/assemblyname.hpp
inc/assemblyname.inl
inc/assemblyversion.hpp
Expand All @@ -40,8 +37,6 @@ set(BINDER_COMMON_HEADERS
inc/failurecachehashtraits.hpp
inc/loadcontext.hpp
inc/loadcontext.inl
inc/stringlexer.hpp
inc/stringlexer.inl
inc/textualidentityparser.hpp
inc/utils.hpp
)
Expand Down
34 changes: 0 additions & 34 deletions src/coreclr/binder/applicationcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "stringarraylist.h"
#include "loadcontext.hpp"
#include "failurecache.hpp"
#include "assemblyidentitycache.hpp"
#include "utils.hpp"
#include "ex.h"
#include "clr/fs/path.h"
Expand Down Expand Up @@ -216,39 +215,6 @@ namespace BINDER_SPACE
return hr;
}

HRESULT ApplicationContext::GetAssemblyIdentity(LPCSTR szTextualIdentity,
AssemblyIdentityUTF8 **ppAssemblyIdentity)
{
HRESULT hr = S_OK;

_ASSERTE(szTextualIdentity != NULL);
_ASSERTE(ppAssemblyIdentity != NULL);

CRITSEC_Holder contextLock(GetCriticalSectionCookie());

AssemblyIdentityUTF8 *pAssemblyIdentity = m_assemblyIdentityCache.Lookup(szTextualIdentity);
if (pAssemblyIdentity == NULL)
{
NewHolder<AssemblyIdentityUTF8> pNewAssemblyIdentity;
SString sTextualIdentity;

SAFE_NEW(pNewAssemblyIdentity, AssemblyIdentityUTF8);
sTextualIdentity.SetUTF8(szTextualIdentity);

IF_FAIL_GO(TextualIdentityParser::Parse(sTextualIdentity, pNewAssemblyIdentity));
IF_FAIL_GO(m_assemblyIdentityCache.Add(szTextualIdentity, pNewAssemblyIdentity));

pNewAssemblyIdentity->PopulateUTF8Fields();

pAssemblyIdentity = pNewAssemblyIdentity.Extract();
}

*ppAssemblyIdentity = pAssemblyIdentity;

Exit:
return hr;
}

bool ApplicationContext::IsTpaListProvided()
{
return m_pTrustedPlatformAssemblyMap != nullptr;
Expand Down
64 changes: 0 additions & 64 deletions src/coreclr/binder/assemblyidentitycache.cpp

This file was deleted.

6 changes: 0 additions & 6 deletions src/coreclr/binder/inc/applicationcontext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "bindertypes.hpp"
#include "failurecache.hpp"
#include "assemblyidentitycache.hpp"
#include "stringarraylist.h"

namespace BINDER_SPACE
Expand Down Expand Up @@ -94,9 +93,6 @@ namespace BINDER_SPACE
/* in */ SString &sAppPaths,
/* in */ BOOL fAcquireLock);

HRESULT GetAssemblyIdentity(/* in */ LPCSTR szTextualIdentity,
/* in */ AssemblyIdentityUTF8 **ppAssemblyIdentity);

// Getters/Setter
inline ExecutionContext *GetExecutionContext();
inline FailureCache *GetFailureCache();
Expand All @@ -119,8 +115,6 @@ namespace BINDER_SPACE
FailureCache *m_pFailureCache;
CRITSEC_COOKIE m_contextCS;

AssemblyIdentityCache m_assemblyIdentityCache;

StringArrayList m_platformResourceRoots;
StringArrayList m_appPaths;

Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/binder/inc/assemblybindercommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ class PEImage;

namespace BINDER_SPACE
{
class AssemblyIdentityUTF8;

class AssemblyBinderCommon
{
public:
Expand Down
43 changes: 0 additions & 43 deletions src/coreclr/binder/inc/assemblyidentity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,49 +81,6 @@ namespace BINDER_SPACE
AssemblyContentType m_kContentType;
DWORD m_dwIdentityFlags;
};

class AssemblyIdentityUTF8 final : public AssemblyIdentity
{
public:
AssemblyIdentityUTF8()
{
m_szSimpleNameUTF8 = NULL;
m_szCultureOrLanguageUTF8 = NULL;
}

void PopulateUTF8Fields()
{
m_szSimpleNameUTF8 = m_simpleName.GetUTF8(sSimpleNameBuffer);

if (Have(IDENTITY_FLAG_CULTURE) && !m_cultureOrLanguage.IsEmpty())
{
m_szCultureOrLanguageUTF8 = m_cultureOrLanguage.GetUTF8(sCultureBuffer);
}
}

inline LPCSTR GetSimpleNameUTF8()
{
return m_szSimpleNameUTF8;
}

inline LPCSTR GetCultureOrLanguageUTF8()
{
return m_szCultureOrLanguageUTF8;
}

inline const BYTE *GetPublicKeyOrTokenArray()
{
const BYTE *pPublicKeyOrToken = m_publicKeyOrTokenBLOB;

return pPublicKeyOrToken;
}

protected:
StackScratchBuffer sSimpleNameBuffer;
StackScratchBuffer sCultureBuffer;
LPCSTR m_szSimpleNameUTF8;
LPCSTR m_szCultureOrLanguageUTF8;
};
};

#endif
114 changes: 0 additions & 114 deletions src/coreclr/binder/inc/assemblyidentitycache.hpp

This file was deleted.

Loading