Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d37d5e4
Make SString generic on an encoding traits type.
jkoritzinsky May 23, 2022
42fa6ab
Merge branch 'main' of github.com:dotnet/runtime into sstring-explici…
jkoritzinsky May 23, 2022
f913366
Fix linux build
jkoritzinsky May 24, 2022
32ddf53
Rename a few things to reduce the overall number of changes.
jkoritzinsky May 24, 2022
b2588e6
Fix linux build.
jkoritzinsky May 24, 2022
bc07888
A few more changes to reduce diffs.
jkoritzinsky May 24, 2022
8ebc5df
More diff reduction
jkoritzinsky May 24, 2022
0a5056c
Various fixes for SString. Reimplement the move semantics on SBuffer …
jkoritzinsky May 25, 2022
26f4944
Fix base type member usage with templates
jkoritzinsky May 26, 2022
824aa67
Store the result of GetPathToLoad in a local so we don't trash GetLas…
jkoritzinsky May 26, 2022
b146aae
Fix reuse bug in assembly loading.
jkoritzinsky May 27, 2022
e95cbef
Merge branch 'main' of github.com:dotnet/runtime into sstring-explici…
jkoritzinsky Jun 2, 2022
1a4d621
Merge branch 'sstring-explicit-encoding' of github.com:jkoritzinsky/r…
jkoritzinsky Jun 2, 2022
7b87012
Remove outdated comment
jkoritzinsky Jun 2, 2022
a7dcfad
Fix unix build
jkoritzinsky Jun 2, 2022
c445d35
Fix immutable empty shortcut and additional cleanup.
jkoritzinsky Jun 6, 2022
84876d8
Add static_assert message
jkoritzinsky Jun 6, 2022
2f01a7a
Fix cast issue on 32-bit
jkoritzinsky Jun 7, 2022
5aa2896
Fix default constructor to correctly mark UTF8/ASCII default EStrings…
jkoritzinsky Jun 7, 2022
b4d2fbd
Various fixes
jkoritzinsky Jun 7, 2022
bcfd0b7
Fix canary and buffer sharing handling. Fix another constructor that …
jkoritzinsky Jun 8, 2022
5a22849
Merge branch 'main' into sstring-explicit-encoding
jkoritzinsky Jun 8, 2022
7523a1f
Fix build break
jkoritzinsky Jun 9, 2022
a6fc06d
Fix super-large array rank error case handling.
jkoritzinsky Jun 9, 2022
5f53cc7
Fix some typos from bad find-replace in nativeaot code
jkoritzinsky Jun 9, 2022
93e98cf
Merge branch 'main' of github.com:dotnet/runtime into sstring-explici…
jkoritzinsky Jun 14, 2022
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
Next Next commit
Make SString generic on an encoding traits type.
  • Loading branch information
jkoritzinsky committed May 23, 2022
commit d37d5e4c44b80be9dd80522ea4d4e6cdacc3f539
30 changes: 13 additions & 17 deletions src/coreclr/binder/applicationcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ namespace BINDER_SPACE
return hr;
}

HRESULT ApplicationContext::SetupBindingPaths(SString &sTrustedPlatformAssemblies,
SString &sPlatformResourceRoots,
SString &sAppPaths,
HRESULT ApplicationContext::SetupBindingPaths(SString<EncodingUnicode> &sTrustedPlatformAssemblies,
SString<EncodingUnicode> &sPlatformResourceRoots,
SString<EncodingUnicode> &sAppPaths,
BOOL fAcquireLock)
{
HRESULT hr = S_OK;
Expand All @@ -96,12 +96,10 @@ namespace BINDER_SPACE
//
m_pTrustedPlatformAssemblyMap = new SimpleNameToFileNameMap();

sTrustedPlatformAssemblies.Normalize();

for (SString::Iterator i = sTrustedPlatformAssemblies.Begin(); i != sTrustedPlatformAssemblies.End(); )
for (SString<EncodingUnicode>::Iterator i = sTrustedPlatformAssemblies.Begin(); i != sTrustedPlatformAssemblies.End(); )
{
SString fileName;
SString simpleName;
SString<EncodingUnicode> fileName;
SString<EncodingUnicode> simpleName;
bool isNativeImage = false;
HRESULT pathResult = S_OK;
IF_FAIL_GO(pathResult = GetNextTPAPath(sTrustedPlatformAssemblies, i, /*dllOnly*/ false, fileName, simpleName, isNativeImage));
Expand All @@ -110,7 +108,7 @@ namespace BINDER_SPACE
break;
}

const SimpleNameToFileNameMapEntry *pExistingEntry = m_pTrustedPlatformAssemblyMap->LookupPtr(simpleName.GetUnicode());
const SimpleNameToFileNameMapEntry *pExistingEntry = m_pTrustedPlatformAssemblyMap->LookupPtr(simpleName);

if (pExistingEntry != nullptr)
{
Expand All @@ -135,7 +133,7 @@ namespace BINDER_SPACE
{
GO_WITH_HRESULT(E_OUTOFMEMORY);
}
wcscpy_s(wszSimpleName, simpleName.GetCount() + 1, simpleName.GetUnicode());
wcscpy_s(wszSimpleName, simpleName.GetCount() + 1, simpleName);
}
else
{
Expand All @@ -147,7 +145,7 @@ namespace BINDER_SPACE
{
GO_WITH_HRESULT(E_OUTOFMEMORY);
}
wcscpy_s(wszFileName, fileName.GetCount() + 1, fileName.GetUnicode());
wcscpy_s(wszFileName, fileName.GetCount() + 1, fileName);

SimpleNameToFileNameMapEntry mapEntry;
mapEntry.m_wszSimpleName = wszSimpleName;
Expand All @@ -168,10 +166,9 @@ namespace BINDER_SPACE
//
// Parse PlatformResourceRoots
//
sPlatformResourceRoots.Normalize();
for (SString::Iterator i = sPlatformResourceRoots.Begin(); i != sPlatformResourceRoots.End(); )
for (SString<EncodingUnicode>::Iterator i = sPlatformResourceRoots.Begin(); i != sPlatformResourceRoots.End(); )
{
SString pathName;
SString<EncodingUnicode> pathName;
HRESULT pathResult = S_OK;

IF_FAIL_GO(pathResult = GetNextPath(sPlatformResourceRoots, i, pathName));
Expand All @@ -191,10 +188,9 @@ namespace BINDER_SPACE
//
// Parse AppPaths
//
sAppPaths.Normalize();
for (SString::Iterator i = sAppPaths.Begin(); i != sAppPaths.End(); )
for (SString<EncodingUnicode>::Iterator i = sAppPaths.Begin(); i != sAppPaths.End(); )
{
SString pathName;
SString<EncodingUnicode> pathName;
HRESULT pathResult = S_OK;

IF_FAIL_GO(pathResult = GetNextPath(sAppPaths, i, pathName));
Expand Down
70 changes: 35 additions & 35 deletions src/coreclr/binder/assemblybindercommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ namespace BINDER_SPACE
}

/* static */
HRESULT AssemblyBinderCommon::BindToSystem(SString &systemDirectory,
HRESULT AssemblyBinderCommon::BindToSystem(SString<EncodingUnicode> &systemDirectory,
Assembly **ppSystemAssembly)
{
HRESULT hr = S_OK;
Expand All @@ -269,8 +269,8 @@ namespace BINDER_SPACE
// * Absolute path when looking for a file on disk
// * Bundle-relative path when looking within the single-file bundle.

StackSString sCoreLibName(CoreLibName_IL_W);
StackSString sCoreLib;
StackSString<EncodingUnicode> sCoreLibName(CoreLibName_IL_W);
StackSString<EncodingUnicode> sCoreLib;
BinderTracing::PathSource pathSource = BinderTracing::PathSource::Bundle;
BundleFileLocation bundleFileLocation = Bundle::ProbeAppBundle(sCoreLibName, /*pathIsBundleRelative */ true);
if (!bundleFileLocation.IsValid())
Expand All @@ -290,15 +290,14 @@ namespace BINDER_SPACE
if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
{
// Try to find corelib in the TPA
StackSString sCoreLibSimpleName(CoreLibName_W);
StackSString sTrustedPlatformAssemblies = Configuration::GetKnobStringValue(W("TRUSTED_PLATFORM_ASSEMBLIES"));
sTrustedPlatformAssemblies.Normalize();
StackSString<EncodingUnicode> sCoreLibSimpleName(CoreLibName_W);
StackSString<EncodingUnicode> sTrustedPlatformAssemblies = Configuration::GetKnobStringValue(W("TRUSTED_PLATFORM_ASSEMBLIES"));

bool found = false;
for (SString::Iterator i = sTrustedPlatformAssemblies.Begin(); i != sTrustedPlatformAssemblies.End(); )
for (SString<EncodingUnicode>::Iterator i = sTrustedPlatformAssemblies.Begin(); i != sTrustedPlatformAssemblies.End(); )
{
SString fileName;
SString simpleName;
SString<EncodingUnicode> fileName;
SString<EncodingUnicode> simpleName;
bool isNativeImage = false;
HRESULT pathResult = S_OK;
IF_FAIL_GO(pathResult = GetNextTPAPath(sTrustedPlatformAssemblies, i, /*dllOnly*/ true, fileName, simpleName, isNativeImage));
Expand All @@ -309,7 +308,7 @@ namespace BINDER_SPACE

if (simpleName.EqualsCaseInsensitive(sCoreLibSimpleName))
{
sCoreLib = fileName;
sCoreLib = (LPCWSTR)fileName;
found = true;
break;
}
Expand Down Expand Up @@ -338,17 +337,17 @@ namespace BINDER_SPACE


/* static */
HRESULT AssemblyBinderCommon::BindToSystemSatellite(SString& systemDirectory,
SString& simpleName,
SString& cultureName,
HRESULT AssemblyBinderCommon::BindToSystemSatellite(SString<EncodingUnicode>& systemDirectory,
SString<EncodingUnicode>& simpleName,
SString<EncodingUnicode>& cultureName,
Assembly** ppSystemAssembly)
{
HRESULT hr = S_OK;

_ASSERTE(ppSystemAssembly != NULL);

// Satellite assembly's relative path
StackSString relativePath;
StackSString<EncodingUnicode> relativePath;

// append culture name
if (!cultureName.IsEmpty())
Expand All @@ -365,7 +364,7 @@ namespace BINDER_SPACE
// Satellite assembly's path:
// * Absolute path when looking for a file on disk
// * Bundle-relative path when looking within the single-file bundle.
StackSString sCoreLibSatellite;
StackSString<EncodingUnicode> sCoreLibSatellite;

BinderTracing::PathSource pathSource = BinderTracing::PathSource::Bundle;
BundleFileLocation bundleFileLocation = Bundle::ProbeAppBundle(relativePath, /*pathIsBundleRelative */ true);
Expand Down Expand Up @@ -592,9 +591,9 @@ namespace BINDER_SPACE
namespace
{
HRESULT BindSatelliteResourceFromBundle(
AssemblyName* pRequestedAssemblyName,
SString &relativePath,
BindResult* pBindResult)
AssemblyName* pRequestedAssemblyName,
SString<EncodingUnicode> &relativePath,
BindResult* pBindResult)
{
HRESULT hr = S_OK;

Expand Down Expand Up @@ -638,9 +637,9 @@ namespace BINDER_SPACE
}

HRESULT BindSatelliteResourceByProbingPaths(
const StringArrayList *pResourceRoots,
const StringArrayList<EncodingUnicode> *pResourceRoots,
AssemblyName *pRequestedAssemblyName,
SString &relativePath,
SString<EncodingUnicode>&relativePath,
BindResult *pBindResult,
BinderTracing::PathSource pathSource)
{
Expand All @@ -649,8 +648,8 @@ namespace BINDER_SPACE
for (UINT i = 0; i < pResourceRoots->GetCount(); i++)
{
ReleaseHolder<Assembly> pAssembly;
SString &wszBindingPath = (*pResourceRoots)[i];
SString fileName(wszBindingPath);
SString<EncodingUnicode> &wszBindingPath = (*pResourceRoots)[i];
SString<EncodingUnicode> fileName(wszBindingPath);
CombinePath(fileName, relativePath, fileName);

hr = AssemblyBinderCommon::GetAssembly(fileName,
Expand Down Expand Up @@ -702,13 +701,13 @@ namespace BINDER_SPACE
// names as platform ones.

HRESULT hr = S_OK;
const SString& simpleNameRef = pRequestedAssemblyName->GetSimpleName();
SString& cultureRef = pRequestedAssemblyName->GetCulture();
const SString<EncodingUnicode>& simpleNameRef = pRequestedAssemblyName->GetSimpleName();
SString<EncodingUnicode>& cultureRef = pRequestedAssemblyName->GetCulture();

_ASSERTE(!pRequestedAssemblyName->IsNeutralCulture());

ReleaseHolder<Assembly> pAssembly;
SString fileName;
SString<EncodingUnicode> fileName;
CombinePath(fileName, cultureRef, fileName);
CombinePath(fileName, simpleNameRef, fileName);
fileName.Append(W(".dll"));
Expand Down Expand Up @@ -741,11 +740,11 @@ namespace BINDER_SPACE
}

HRESULT BindAssemblyByProbingPaths(
const StringArrayList *pBindingPaths,
const StringArrayList<EncodingUnicode> *pBindingPaths,
AssemblyName *pRequestedAssemblyName,
Assembly **ppAssembly)
{
const SString &simpleName = pRequestedAssemblyName->GetSimpleName();
const SString<EncodingUnicode> &simpleName = pRequestedAssemblyName->GetSimpleName();
BinderTracing::PathSource pathSource = BinderTracing::PathSource::AppPaths;
// Loop through the binding paths looking for a matching assembly
for (DWORD i = 0; i < pBindingPaths->GetCount(); i++)
Expand Down Expand Up @@ -840,7 +839,7 @@ namespace BINDER_SPACE
else
{
ReleaseHolder<Assembly> pTPAAssembly;
const SString& simpleName = pRequestedAssemblyName->GetSimpleName();
const SString<EncodingUnicode>& simpleName = pRequestedAssemblyName->GetSimpleName();

// Is assembly in the bundle?
// Single-file bundle contents take precedence over TPA.
Expand All @@ -856,10 +855,11 @@ namespace BINDER_SPACE
// Loop through the binding paths looking for a matching assembly
for (int i = 0; i < 2; i++)
{
SString assemblyFileName(simpleName);
SString<EncodingUnicode> assemblyFileName(simpleName);
assemblyFileName.Append(candidates[i]);

SString assemblyFilePath(Bundle::AppBundle->BasePath());
SString<EncodingUnicode> assemblyFilePath;
Bundle::AppBundle->BasePath().ConvertToUnicode(assemblyFilePath);
assemblyFilePath.Append(assemblyFileName);

BundleFileLocation bundleFileLocation = Bundle::ProbeAppBundle(assemblyFileName, /* pathIsBundleRelative */ true);
Expand Down Expand Up @@ -891,12 +891,12 @@ namespace BINDER_SPACE

// Is assembly on TPA list?
SimpleNameToFileNameMap * tpaMap = pApplicationContext->GetTpaList();
const SimpleNameToFileNameMapEntry *pTpaEntry = tpaMap->LookupPtr(simpleName.GetUnicode());
const SimpleNameToFileNameMapEntry *pTpaEntry = tpaMap->LookupPtr(simpleName);
if (pTpaEntry != nullptr)
{
if (pTpaEntry->m_wszNIFileName != nullptr)
{
SString fileName(pTpaEntry->m_wszNIFileName);
SString<EncodingUnicode> fileName(pTpaEntry->m_wszNIFileName);

hr = GetAssembly(fileName,
TRUE, // fIsInTPA
Expand All @@ -906,7 +906,7 @@ namespace BINDER_SPACE
else
{
_ASSERTE(pTpaEntry->m_wszILFileName != nullptr);
SString fileName(pTpaEntry->m_wszILFileName);
SString<EncodingUnicode> fileName(pTpaEntry->m_wszILFileName);

hr = GetAssembly(fileName,
TRUE, // fIsInTPA
Expand Down Expand Up @@ -994,7 +994,7 @@ namespace BINDER_SPACE
}

/* static */
HRESULT AssemblyBinderCommon::GetAssembly(SString &assemblyPath,
HRESULT AssemblyBinderCommon::GetAssembly(SString<EncodingUnicode> &assemblyPath,
BOOL fIsInTPA,
Assembly **ppAssembly,
BundleFileLocation bundleFileLocation)
Expand All @@ -1011,7 +1011,7 @@ namespace BINDER_SPACE

// Obtain assembly meta data
{
LPCTSTR szAssemblyPath = const_cast<LPCTSTR>(assemblyPath.GetUnicode());
LPCTSTR szAssemblyPath = static_cast<LPCTSTR>(assemblyPath);

hr = BinderAcquirePEImage(szAssemblyPath, &pPEImage, bundleFileLocation);
IF_FAIL_GO(hr);
Expand Down
38 changes: 20 additions & 18 deletions src/coreclr/binder/assemblyname.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,31 @@ namespace BINDER_SPACE
));

{
StackSString culture;
culture.SetUTF8(amd.szLocale);
culture.Normalize();
StackSString<EncodingUTF8> culture(amd.szLocale);
SString<EncodingUnicode> cultureUnicode;
culture.ConvertToUnicode(cultureUnicode);

SString::CIterator itr = culture.Begin();
if (culture.Find(itr, L';'))
SString<EncodingUnicode>::CIterator itr = cultureUnicode.Begin();
if (cultureUnicode.Find(itr, L';'))
{
culture = SString(culture, culture.Begin(), itr-1);
cultureUnicode = SString<EncodingUnicode>(cultureUnicode, cultureUnicode.Begin(), itr-1);
}

SetCulture(culture);
SetCulture(cultureUnicode);
}

{
StackSString assemblyName;
assemblyName.SetUTF8(pAssemblyName);
assemblyName.Normalize();
StackSString<EncodingUTF8> assemblyName(pAssemblyName);
SString<EncodingUnicode> assemblyNameUnicode;
assemblyName.ConvertToUnicode(assemblyNameUnicode);

COUNT_T assemblyNameLength = assemblyName.GetCount();
if (assemblyNameLength == 0 || assemblyNameLength >= MAX_PATH_FNAME)
{
IF_FAIL_GO(FUSION_E_INVALID_NAME);
}

SetSimpleName(assemblyName);
SetSimpleName(assemblyNameUnicode);
}

// See if the assembly[def] is retargetable (ie, for a generic assembly).
Expand Down Expand Up @@ -159,10 +159,12 @@ namespace BINDER_SPACE
HRESULT AssemblyName::Init(const AssemblyNameData &data)
{
DWORD flags = data.IdentityFlags;
m_simpleName.SetUTF8(data.Name);
MAKE_WIDEPTR_FROMUTF8(pSimpleName, data.Name);
m_simpleName.Set(pSimpleName);
m_version.SetFeatureVersion(data.MajorVersion, data.MinorVersion);
m_version.SetServiceVersion(data.BuildNumber, data.RevisionNumber);
m_cultureOrLanguage.SetUTF8(data.Culture);
MAKE_WIDEPTR_FROMUTF8(pCulture, data.Culture);
m_cultureOrLanguage.Set(pCulture);

m_publicKeyOrTokenBLOB.Set(data.PublicKeyOrToken, data.PublicKeyOrTokenLength);
if ((flags & BINDER_SPACE::AssemblyIdentity::IDENTITY_FLAG_PUBLIC_KEY) != 0)
Expand Down Expand Up @@ -204,13 +206,13 @@ namespace BINDER_SPACE
BOOL AssemblyName::IsCoreLib()
{
// TODO: Is this simple comparison enough?
return SString::_wcsicmp(GetSimpleName().GetUnicode(), CoreLibName_W) == 0;
return StaticStringHelpers::_wcsicmp(GetSimpleName(), CoreLibName_W) == 0;
}

bool AssemblyName::IsNeutralCulture()
{
return m_cultureOrLanguage.IsEmpty()
|| SString::_wcsicmp(m_cultureOrLanguage.GetUnicode(), s_neutralCulture) == 0;
|| StaticStringHelpers::_wcsicmp(m_cultureOrLanguage, s_neutralCulture) == 0;
}

ULONG AssemblyName::Hash(DWORD dwIncludeFlags)
Expand Down Expand Up @@ -350,7 +352,7 @@ namespace BINDER_SPACE
return fEquals;
}

void AssemblyName::GetDisplayName(PathString &displayName,
void AssemblyName::GetDisplayName(SString<EncodingUnicode> &displayName,
DWORD dwIncludeFlags)
{
DWORD dwUseIdentityFlags = m_dwIdentityFlags;
Expand All @@ -376,9 +378,9 @@ namespace BINDER_SPACE
TextualIdentityParser::ToString(this, dwUseIdentityFlags, displayName);
}

SString &AssemblyName::GetNormalizedCulture()
SString<EncodingUnicode> &AssemblyName::GetNormalizedCulture()
{
SString &culture = GetCulture();
SString<EncodingUnicode> &culture = GetCulture();

if (culture.IsEmpty())
{
Expand Down
Loading