Skip to content

Commit 805ac0b

Browse files
authored
Remove localization support for native resource (#122025)
If we ever want to bring back the localization, we should be depending on MUI or other solutions.
1 parent 59a29ee commit 805ac0b

File tree

6 files changed

+25
-652
lines changed

6 files changed

+25
-652
lines changed

src/coreclr/inc/clrnt.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
#define STATUS_LONGJUMP ((NTSTATUS)0x80000026L)
3434
#endif
3535

36-
#ifndef LOCALE_NAME_MAX_LENGTH
37-
#define LOCALE_NAME_MAX_LENGTH 85
38-
#endif // !LOCALE_NAME_MAX_LENGTH
39-
4036
#ifndef IMAGE_FILE_MACHINE_RISCV64
4137
#define IMAGE_FILE_MACHINE_RISCV64 0x5064 // RISCV64
4238
#endif // !IMAGE_FILE_MACHINE_RISCV64

src/coreclr/inc/utilcode.h

Lines changed: 5 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -342,30 +342,6 @@ inline HRESULT OutOfMemory()
342342
}
343343
#endif
344344

345-
//*****************************************************************************
346-
// Handle accessing localizable resource strings
347-
//*****************************************************************************
348-
typedef LPCWSTR LocaleID;
349-
typedef WCHAR LocaleIDValue[LOCALE_NAME_MAX_LENGTH];
350-
351-
// Notes about the culture callbacks:
352-
// - The language we're operating in can change at *runtime*!
353-
// - A process may operate in *multiple* languages.
354-
// (ex: Each thread may have it's own language)
355-
// - If we don't care what language we're in (or have no way of knowing),
356-
// then return a 0-length name and UICULTUREID_DONTCARE for the culture ID.
357-
// - GetCultureName() and the GetCultureId() must be in sync (refer to the
358-
// same language).
359-
// - We have two functions separate functions for better performance.
360-
// - The name is used to resolve a directory for MsCorRC.dll.
361-
// - The id is used as a key to map to a dll hinstance.
362-
363-
// Callback to obtain both the culture name and the culture's parent culture name
364-
typedef HRESULT (*FPGETTHREADUICULTURENAMES)(__inout StringArrayList* pCultureNames);
365-
const LPCWSTR UICULTUREID_DONTCARE = NULL;
366-
367-
typedef int (*FPGETTHREADUICULTUREID)(LocaleIDValue*);
368-
369345
HMODULE CLRLoadLibrary(LPCWSTR lpLibFileName);
370346

371347
HMODULE CLRLoadLibraryEx(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags);
@@ -375,19 +351,6 @@ BOOL CLRFreeLibrary(HMODULE hModule);
375351
// Load a string using the resources for the current module.
376352
STDAPI UtilLoadStringRC(UINT iResourceID, _Out_writes_ (iMax) LPWSTR szBuffer, int iMax, int bQuiet=FALSE);
377353

378-
// Specify callbacks so that UtilLoadStringRC can find out which language we're in.
379-
// If no callbacks specified (or both parameters are NULL), we default to the
380-
// resource dll in the root (which is probably english).
381-
void SetResourceCultureCallbacks(
382-
FPGETTHREADUICULTURENAMES fpGetThreadUICultureNames,
383-
FPGETTHREADUICULTUREID fpGetThreadUICultureId
384-
);
385-
386-
void GetResourceCultureCallbacks(
387-
FPGETTHREADUICULTURENAMES* fpGetThreadUICultureNames,
388-
FPGETTHREADUICULTUREID* fpGetThreadUICultureId
389-
);
390-
391354
//*****************************************************************************
392355
// Use this class by privately deriving from noncopyable to disallow copying of
393356
// your class.
@@ -414,7 +377,6 @@ typedef HINSTANCE HRESOURCEDLL;
414377

415378
class CCulturedHInstance
416379
{
417-
LocaleIDValue m_LangId;
418380
HRESOURCEDLL m_hInst;
419381
BOOL m_fMissing;
420382

@@ -426,15 +388,6 @@ class CCulturedHInstance
426388
m_fMissing = FALSE;
427389
}
428390

429-
BOOL HasID(LocaleID id)
430-
{
431-
_ASSERTE(m_hInst != NULL || m_fMissing);
432-
if (id == UICULTUREID_DONTCARE)
433-
return FALSE;
434-
435-
return u16_strcmp(id, m_LangId) == 0;
436-
}
437-
438391
HRESOURCEDLL GetLibraryHandle()
439392
{
440393
return m_hInst;
@@ -450,42 +403,23 @@ class CCulturedHInstance
450403
return m_fMissing;
451404
}
452405

453-
void SetMissing(LocaleID id)
406+
void SetMissing()
454407
{
455408
_ASSERTE(m_hInst == NULL);
456-
SetId(id);
457409
m_fMissing = TRUE;
458410
}
459411

460-
void Set(LocaleID id, HRESOURCEDLL hInst)
412+
void Set(HRESOURCEDLL hInst)
461413
{
462414
_ASSERTE(m_hInst == NULL);
463415
_ASSERTE(m_fMissing == FALSE);
464-
SetId(id);
465416
m_hInst = hInst;
466417
}
467-
private:
468-
void SetId(LocaleID id)
469-
{
470-
if (id != UICULTUREID_DONTCARE)
471-
{
472-
wcsncpy_s(m_LangId, ARRAY_SIZE(m_LangId), id, ARRAY_SIZE(m_LangId));
473-
m_LangId[STRING_LENGTH(m_LangId)] = W('\0');
474-
}
475-
else
476-
{
477-
m_LangId[0] = W('\0');
478-
}
479-
}
480418
};
481419

482-
#ifndef DACCESS_COMPILE
483-
void AddThreadPreferredUILanguages(StringArrayList* pArray);
484-
#endif
485420
//*****************************************************************************
486421
// CCompRC manages string Resource access for CLR. This includes loading
487-
// the MsCorRC.dll for resources as well allowing each thread to use a
488-
// a different localized version.
422+
// the MsCorRC.dll for resources. No localization is supported.
489423
//*****************************************************************************
490424
class CCompRC
491425
{
@@ -515,11 +449,6 @@ class CCompRC
515449
{
516450
// This constructor will be fired up on startup. Make sure it doesn't
517451
// do anything besides zero-out out values.
518-
m_fpGetThreadUICultureId = NULL;
519-
m_fpGetThreadUICultureNames = NULL;
520-
521-
m_pHash = NULL;
522-
m_nHashSize = 0;
523452
m_csMap = NULL;
524453
m_pResourceFile = NULL;
525454
}// CCompRC
@@ -528,49 +457,14 @@ class CCompRC
528457
void Destroy();
529458

530459
HRESULT LoadString(ResourceCategory eCategory, UINT iResourceID, _Out_writes_ (iMax) LPWSTR szBuffer, int iMax , int *pcwchUsed=NULL);
531-
HRESULT LoadString(ResourceCategory eCategory, LocaleID langId, UINT iResourceID, _Out_writes_ (iMax) LPWSTR szBuffer, int iMax, int *pcwchUsed);
532-
533-
void SetResourceCultureCallbacks(
534-
FPGETTHREADUICULTURENAMES fpGetThreadUICultureNames,
535-
FPGETTHREADUICULTUREID fpGetThreadUICultureId
536-
);
537-
538-
void GetResourceCultureCallbacks(
539-
FPGETTHREADUICULTURENAMES* fpGetThreadUICultureNames,
540-
FPGETTHREADUICULTUREID* fpGetThreadUICultureId
541-
);
542460

543461
// Get the default resource location (mscorrc.dll)
544462
static CCompRC* GetDefaultResourceDll();
545463

546-
static void GetDefaultCallbacks(
547-
FPGETTHREADUICULTURENAMES* fpGetThreadUICultureNames,
548-
FPGETTHREADUICULTUREID* fpGetThreadUICultureId)
549-
{
550-
WRAPPER_NO_CONTRACT;
551-
m_DefaultResourceDll.GetResourceCultureCallbacks(
552-
fpGetThreadUICultureNames,
553-
fpGetThreadUICultureId);
554-
}
555-
556-
static void SetDefaultCallbacks(
557-
FPGETTHREADUICULTURENAMES fpGetThreadUICultureNames,
558-
FPGETTHREADUICULTUREID fpGetThreadUICultureId)
559-
{
560-
WRAPPER_NO_CONTRACT;
561-
// Either both are NULL or neither are NULL
562-
_ASSERTE((fpGetThreadUICultureNames != NULL) ==
563-
(fpGetThreadUICultureId != NULL));
564-
565-
m_DefaultResourceDll.SetResourceCultureCallbacks(
566-
fpGetThreadUICultureNames,
567-
fpGetThreadUICultureId);
568-
}
569-
570464
private:
571465
// String resources packaged as PE files only exist on Windows
572466
#ifdef HOST_WINDOWS
573-
HRESULT GetLibrary(LocaleID langId, HRESOURCEDLL* phInst);
467+
HRESULT GetLibrary(HRESOURCEDLL* phInst);
574468
#ifndef DACCESS_COMPILE
575469
HRESULT LoadLibraryHelper(HRESOURCEDLL *pHInst,
576470
SString& rcPath);
@@ -585,23 +479,12 @@ class CCompRC
585479
static CCompRC m_DefaultResourceDll;
586480
static LPCWSTR m_pDefaultResource;
587481

588-
// We must map between a thread's int and a dll instance.
589-
// Since we only expect 1 language almost all of the time, we'll special case
590-
// that and then use a variable size map for everything else.
482+
// Use a singleton since we don't support localization any more.
591483
CCulturedHInstance m_Primary;
592-
CCulturedHInstance * m_pHash;
593-
int m_nHashSize;
594484

595485
CRITSEC_COOKIE m_csMap;
596486

597487
LPCWSTR m_pResourceFile;
598-
599-
// Main accessors for hash
600-
HRESOURCEDLL LookupNode(LocaleID langId, BOOL &fMissing);
601-
HRESULT AddMapNode(LocaleID langId, HRESOURCEDLL hInst, BOOL fMissing = FALSE);
602-
603-
FPGETTHREADUICULTUREID m_fpGetThreadUICultureId;
604-
FPGETTHREADUICULTURENAMES m_fpGetThreadUICultureNames;
605488
};
606489

607490
HRESULT UtilLoadResourceString(CCompRC::ResourceCategory eCategory, UINT iResourceID, _Out_writes_ (iMax) LPWSTR szBuffer, int iMax);

src/coreclr/pal/inc/rt/palrt.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -557,14 +557,6 @@ typedef unsigned int ALG_ID;
557557
#define LCMAP_LOWERCASE 0x00000100
558558
#define LCMAP_UPPERCASE 0x00000200
559559

560-
// 8 characters for language
561-
// 8 characters for region
562-
// 64 characters for suffix (script)
563-
// 2 characters for '-' separators
564-
// 2 characters for prefix like "i-" or "x-"
565-
// 1 null termination
566-
#define LOCALE_NAME_MAX_LENGTH 85
567-
568560

569561
#ifdef __cplusplus
570562
/*

0 commit comments

Comments
 (0)