Skip to content

Commit 41b624a

Browse files
Fixed code compilation regression
1 parent a7ebde2 commit 41b624a

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

Source/Libraries/HedgeModManager.CodeCompiler/CSharpCode.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,18 @@ public string GetFullName()
229229
}
230230
}
231231

232+
public string GetIdentifier()
233+
{
234+
if (string.IsNullOrEmpty(ID))
235+
{
236+
return Name;
237+
}
238+
else
239+
{
240+
return ID;
241+
}
242+
}
243+
232244
public List<string> GetReferences()
233245
{
234246
var references = new List<string>();
@@ -288,23 +300,24 @@ public CompilationUnitSyntax CreateCompilationUnit(IIncludeResolver? includeReso
288300

289301
var libNamespace = string.Empty;
290302
var name = string.Empty;
303+
var id = GetIdentifier();
291304

292305
if (Type == CodeType.Library)
293306
{
294-
var dotIdx = Name.LastIndexOf('.');
307+
var dotIdx = id.LastIndexOf('.');
295308
if (dotIdx > 0)
296309
{
297-
name = Name.Substring(dotIdx + 1);
298-
libNamespace = Name.Substring(0, dotIdx);
310+
name = id.Substring(dotIdx + 1);
311+
libNamespace = id.Substring(0, dotIdx);
299312
}
300313
else
301314
{
302-
name = Name;
315+
name = id;
303316
}
304317
}
305318
else
306319
{
307-
name = Regex.Replace($"{Name}_{Guid.NewGuid()}", "[^a-z_0-9]", string.Empty, RegexOptions.IgnoreCase);
320+
name = Regex.Replace($"{id}_{Guid.NewGuid()}", "[^a-z_0-9]", string.Empty, RegexOptions.IgnoreCase);
308321
}
309322

310323
var classUnit = SyntaxFactory

0 commit comments

Comments
 (0)