Skip to content

Commit

Permalink
Throw exception in cases where no valid name can be created
Browse files Browse the repository at this point in the history
  • Loading branch information
gregwinterstein committed Apr 3, 2024
1 parent 5b08989 commit 1f8bb27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Microsoft.OData.CodeGen/Templates/ODataT4CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3070,6 +3070,11 @@ private string GetValidIdentifier(string name)
isFirst = false;
}

if (validName.Length < 1)
{
throw new Exception($"Failed to make valid identifier for '{name}'");
}

if (!char.IsLetter(validName[0]) && validName[0] != DefaultPrefixCharacter)
{
validName.Insert(0, DefaultPrefixCharacter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2925,6 +2925,11 @@ public abstract class ODataClientTemplate : TemplateBase
isFirst = false;
}

if (validName.Length < 1)
{
throw new Exception($"Failed to make valid identifier for '{name}'");
}

if (!char.IsLetter(validName[0]) && validName[0] != DefaultPrefixCharacter)
{
validName.Insert(0, DefaultPrefixCharacter);
Expand Down

0 comments on commit 1f8bb27

Please sign in to comment.