Skip to content

Commit f842a22

Browse files
committed
Adjust C# compilation
1 parent 7e12a3e commit f842a22

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

src.compiler/csharp/CSharpAstTransformer.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2966,11 +2966,10 @@ export default class CSharpAstTransformer {
29662966
return 'TrimStart';
29672967
}
29682968
break;
2969-
case 'NumberConstructor':
29702969
case 'Number':
29712970
switch (symbol.name) {
29722971
case 'toString':
2973-
return 'toInvariantString';
2972+
return 'ToInvariantString';
29742973
}
29752974
break;
29762975
}

src.compiler/csharp/CSharpEmitterContext.ts

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -770,23 +770,26 @@ export default class CSharpEmitterContext {
770770

771771
protected buildCoreNamespace(aliasSymbol: ts.Symbol) {
772772
let suffix = '';
773-
for (const decl of aliasSymbol.declarations) {
774-
let fileName = path.basename(decl.getSourceFile().fileName).toLowerCase();
775-
if (fileName.startsWith('lib.') && fileName.endsWith('.d.ts')) {
776-
fileName = fileName.substring(4, fileName.length - 5);
777-
if (fileName.length) {
778-
suffix = fileName.split('.').map(s => {
779-
if (s.match(/es[0-9]{4}/)) {
780-
return '.' + this.toPascalCase('ecmaScript');
781-
}
782-
if (s.match(/es[0-9]{1}/)) {
783-
return '.' + this.toPascalCase('ecmaScript');
784-
}
785-
return '.' + this.toPascalCase(s);
786-
})[0];
773+
if (aliasSymbol.name !== 'Map') {
774+
for (const decl of aliasSymbol.declarations) {
775+
let fileName = path.basename(decl.getSourceFile().fileName).toLowerCase();
776+
if (fileName.startsWith('lib.') && fileName.endsWith('.d.ts')) {
777+
fileName = fileName.substring(4, fileName.length - 5);
778+
if (fileName.length) {
779+
suffix = fileName.split('.').map(s => {
780+
if (s.match(/es[0-9]{4}/)) {
781+
return '.' + this.toPascalCase('ecmaScript');
782+
}
783+
if (s.match(/es[0-9]{1}/)) {
784+
return '.' + this.toPascalCase('ecmaScript');
785+
}
786+
return '.' + this.toPascalCase(s);
787+
})[0];
788+
}
787789
}
788790
}
789791
}
792+
790793
return this.toPascalCase('alphaTab.core') + suffix + '.';
791794
}
792795
protected toCoreTypeName(s: string) {

src.csharp/AlphaTab/Core/TypeHelper.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public static KeyValuePair<TKey, TValue> CreateMapEntry<TKey, TValue>(TKey key,
266266
return new KeyValuePair<TKey, TValue>(key, value);
267267
}
268268

269-
public static string ToString(this double num, int radix)
269+
public static string ToInvariantString(this double num, int radix)
270270
{
271271
if (radix == 16)
272272
{
@@ -276,6 +276,21 @@ public static string ToString(this double num, int radix)
276276
return num.ToString(CultureInfo.InvariantCulture);
277277
}
278278

279+
public static string ToInvariantString(this double num)
280+
{
281+
return num.ToString(CultureInfo.InvariantCulture);
282+
}
283+
284+
public static string ToInvariantString(this int num)
285+
{
286+
return num.ToString(CultureInfo.InvariantCulture);
287+
}
288+
289+
public static string ToInvariantString(this Enum num)
290+
{
291+
return ((IConvertible)num).ToInt32(CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture);
292+
}
293+
279294
[MethodImpl(MethodImplOptions.AggressiveInlining)]
280295
public static RegExp CreateRegex(string pattern, string flags)
281296
{

0 commit comments

Comments
 (0)