mirror of
https://github.com/actions/runner.git
synced 2025-12-17 07:54:19 +00:00
Compare updated template evaluator (#4092)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#nullable disable // Consider removing in the future to minimize likelihood of NullReferenceException; refer https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references
|
||||
|
||||
using System;
|
||||
|
||||
namespace GitHub.Actions.WorkflowParser.ObjectTemplating.Tokens
|
||||
{
|
||||
public abstract class ScalarToken : TemplateToken
|
||||
{
|
||||
protected ScalarToken(
|
||||
Int32 type,
|
||||
Int32? fileId,
|
||||
Int32? line,
|
||||
Int32? column)
|
||||
: base(type, fileId, line, column)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual String ToDisplayString()
|
||||
{
|
||||
return TrimDisplayString(ToString());
|
||||
}
|
||||
|
||||
protected String TrimDisplayString(String displayString)
|
||||
{
|
||||
var firstLine = displayString.TrimStart(' ', '\t', '\r', '\n');
|
||||
var firstNewLine = firstLine.IndexOfAny(new[] { '\r', '\n' });
|
||||
if (firstNewLine >= 0)
|
||||
{
|
||||
firstLine = firstLine.Substring(0, firstNewLine);
|
||||
}
|
||||
return firstLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user