# GenerateYarnFileWithDeclarations(IEnumerable\<Yarn.Compiler.Declaration>,string,IEnumerable\<string>?,IDictionary\<string, string>?)

Method in [Utility](https://docs.yarnspinner.dev/api/csharp/yarn.compiler/yarn.compiler.utility)

## Summary

Generates a Yarn script that contains a node that declares variables.

```csharp
public static string GenerateYarnFileWithDeclarations(IEnumerable<Yarn.Compiler.Declaration> declarations, string title = "Program", IEnumerable<string>? tags = null, IDictionary<string, string>? headers = null)
```

## Remarks

This method is intended to be called by tools that let the user manage variable declarations. Such tools can read the existing variable declarations in from a script (by compiling the script with the [CompilationType](https://docs.yarnspinner.dev/api/csharp/yarn.compiler/yarn.compiler.compilationjob/yarn.compiler.compilationjob.compilationtype) value set to [TypeCheck](https://docs.yarnspinner.dev/api/csharp/yarn.compiler/yarn.compiler.compilationjob/yarn.compiler.compilationjob.type/yarn.compiler.compilationjob.type.typecheck) ), allow the user to make changes, and then write the changes to disk by calling this method and saving the results.

## Parameters

| Name                                                                             | Description                                                                                                                                        |
| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `System.Collections.Generic.IEnumerable<Yarn.Compiler.Declaration>` declarations | The collection of [Declaration](https://docs.yarnspinner.dev/api/csharp/yarn.compiler/yarn.compiler.declaration) objects to include in the output. |
| `string` title                                                                   | The title of the node that should be generated.                                                                                                    |
| `System.Collections.Generic.IEnumerable<string>` tags                            | The collection of tags that should be generated for the node. If this is `null` , no tags will be generated.                                       |
| `System.Collections.Generic.IDictionary<string, string>` headers                 | The collection of additional headers that should be generated for the node. If this is `null` , no additional headers will be generated.           |

## Returns

A string containing a Yarn script that declares the specified variables.


---

# 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/api/csharp/yarn.compiler/yarn.compiler.utility/yarn.compiler.utility.generateyarnfilewithdeclarations.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.
