# Utility

Class in [Yarn.Compiler](/3.1/api/csharp/yarn.compiler.md)

Inherits from `System.Object`

## Summary

Utility methods for working with line tags.

```csharp
public static class Utility
```

## Methods

| Name                                                                                                                                                                                                                                         | Description                                                                                                                               |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| [AddTagsToLines(string,ICollection?)](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.addtagstolines.md)                                                                                                           | Given Yarn source code, adds line tags to the ends of all lines that need one and do not already have one.                                |
| [DetermineNodeConnections(string\[\])](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.determinenodeconnections.md)                                                                                                | Finds and collates every jump in every node.                                                                                              |
| [ExtractStringBlocks(IEnumerable,ProjectDebugInfo)](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.extractstringblocks.md)                                                                                        | Gets the collection of contiguous runs of lines in the provided nodes. Each run of lines is guaranteed to run to completion once entered. |
| [GenerateYarnFileWithDeclarations(IEnumerable\<Yarn.Compiler.Declaration>,string,IEnumerable?,IDictionary\<string, string>?)](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.generateyarnfilewithdeclarations.md) | Generates a Yarn script that contains a node that declares variables.                                                                     |
| [GetCompiledCodeAsString(Program,Library?,CompilationResult?)](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.getcompiledcodeasstring.md)                                                                         | Gets a string containing a representation of the compiled bytecode for a [Program](/3.1/api/csharp/yarn/yarn.program.md) .                |
| [GetRange(ParserRuleContext)](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.getrange.md)                                                                                                                         | Gets the range covered by a `Antlr4.Runtime.ParserRuleContext` in the source code.                                                        |
| [GetYarnValue(IConvertible)](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.getyarnvalue.md)                                                                                                                      | Returns an [IYarnValue](/3.1/api/csharp/yarn/yarn.iyarnvalue.md) representation of the provided value.                                    |
| [ParseSource(string)](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.parsesource.md)                                                                                                                              | Parses a string of Yarn source code, and produces a FileParseResult and (if there were any problems) a collection of diagnostics.         |
| [ParseSourceText(string,string)](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.parsesourcetext.md)                                                                                                               | Parses a string of Yarn source code, and produces a [FileParseResult](/3.1/api/csharp/yarn.compiler/yarn.compiler.fileparseresult.md) .   |
| [TagLines(string,ICollection?)](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.taglines.md)                                                                                                                       | Given Yarn source code, adds line tags to the ends of all lines that need one and do not already have one.                                |
| [TryGetNodeTitle(string?,YarnSpinnerParser.NodeContext,string?,string?,string?,string?)](/3.1/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.trygetnodetitle.md)                                                       | Gets the title for a node as defined in the source code, along with its unique title (which may be different to the source title.)        |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yarnspinner.dev/3.1/api/csharp/yarn.compiler/yarn.compiler.utility.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
