Skip to content
RustPluginGenerator
CS1513Oxide + Carbon

Fix CS1513: } expected in Oxide plugins (AutoBroadcast example)

CS1513 means the C# compiler reached the end of the file while a brace block was still open, so a closing brace is missing. Find the unbalanced block (usually the class or namespace) and close it, then reload the plugin.

Server console
Error while compiling AutoBroadcast:
[1] } expected at 49:10

Why it happens

Every { in a C# file must be matched by a }. When the compiler hits end-of-file with an open block, Roslyn reports CS1513 at the last line plus one, so the position in the Oxide line (at 58:2) points past the end of your code, not at the real mistake. Common triggers in Oxide plugins:

  • The final } of the class or of namespace Oxide.Plugins was deleted while editing, so the whole file ends one or two braces short.
  • A brace pair was pasted without its counterpart, for example a new method body added above an existing method and the new method's closing brace swallowed the next one's.
  • A GetEnumerator() block or an if/for body was edited and lost its closing brace.
  • Braces inside a verbatim or interpolated string were miscounted, so the code after the string ended up one block deeper than intended.

Oxide compiles the file with Roslyn in one pass; a single CS1513 stops the plugin from loading until it is corrected.

How to fix it

  1. Read the reported position as end-of-file plus one. The mistake is above it, somewhere a block was never closed.
  2. Use a brace-aware editor. In VS Code, Ctrl+Shift+P → "Go to Bracket" or the built-in bracket pair colorizer shows the unmatched {.
  3. Work outward: check that each method, each nested class, the plugin class and the namespace all end with their own }.
  4. Re-indent the whole file (VS Code: Shift+Alt+F). A block that sits at the wrong indentation level is almost always the one missing its brace.
  5. Save the file. Oxide reloads it automatically; alternatively run oxide.reload AutoBroadcast.
  6. Confirm the fix: the Error while compiling AutoBroadcast line disappears and Loaded plugin AutoBroadcast v1.0.0 by RustPluginGenerator (or your title/version) appears in the console. There is no success message beyond that.

Before and after

BeforeFails
using System.Collections.Generic;
using Oxide.Core.Libraries.Covalence;

namespace Oxide.Plugins
{
    [Info("AutoBroadcast", "RustPluginGenerator", "1.0.0")]
    [Description("Broadcasts a rotating list of messages on a timer")]
    public class AutoBroadcast : RustPlugin
    {
        private List<string> messages;
        private int index;

        protected override void LoadDefaultConfig()
        {
            Config["Messages"] = new List<string>
            {
                "Welcome to the server",
                "Type /help for commands",
                "Report bugs on Discord"
            };
            Config["IntervalSeconds"] = 300;
        }

        private void Init()
        {
            messages = Config.Get<List<string>>("Messages");
            timer.Every(Config.Get<float>("IntervalSeconds"), BroadcastNext);
        }

        private void BroadcastNext()
        {
            if (messages == null || messages.Count == 0)
            {
                return;
            }

            if (index >= messages.Count)
            {
                index = 0;
            }

            Server.Broadcast(messages[index]);
            index++;
        }

        private void Unload()
        {
            messages = null;
        }
AfterFixed
using System.Collections.Generic;

namespace Oxide.Plugins
{
    [Info("AutoBroadcast", "RustPluginGenerator", "1.0.0")]
    [Description("Broadcasts a rotating list of messages on a timer")]
    public class AutoBroadcast : RustPlugin
    {
        private List<string> messages;
        private int index;
        private Timer broadcastTimer;

        protected override void LoadDefaultConfig()
        {
            Config["Messages"] = new List<string>
            {
                "Welcome to the server",
                "Type /help for commands",
                "Report bugs on Discord"
            };
            Config["IntervalSeconds"] = 300;
        }

        private void Init()
        {
            object rawMessages = Config["Messages"];
            messages = rawMessages as List<string> ?? new List<string>();

            object rawInterval = Config["IntervalSeconds"];
            int interval = rawInterval is int ? (int)rawInterval : 300;
            if (interval <= 0)
            {
                interval = 300;
            }

            broadcastTimer = timer.Every(interval, BroadcastNext);
        }

        private void BroadcastNext()
        {
            if (messages == null || messages.Count == 0)
            {
                return;
            }

            if (index >= messages.Count)
            {
                index = 0;
            }

            Server.Broadcast(messages[index]);
            index++;
        }

        private void Unload()
        {
            if (broadcastTimer != null)
            {
                broadcastTimer.Destroy();
                broadcastTimer = null;
            }

            messages = null;
        }
    }
}

FAQ

The error says `} expected at 58:2` but my file is only 57 lines long. Why?

Roslyn reports the position where it expected to see the closing brace, which is the line after the last line of real code. The missing brace is somewhere above, not on line 58. Find the block whose opening { is never closed and add the matching } there.

Does one CS1513 stop all my plugins from loading?

No. Oxide removes only the failing file from the compile batch and compiles the rest. The other plugins keep working; AutoBroadcast stays unloaded until you save a version that compiles.

Can a missing brace inside a string cause this?

Yes, indirectly. A stray " or an unclosed verbatim string (@"...") makes the compiler treat following code as string content or vice versa, which shifts brace balance. Check strings around the area you last edited as well as the braces themselves.

Different error?

Paste the full console output and get the cause and a fix in plain English.

Open the error explainer

Skip the debugging

Generated plugins are compiled before you get them, and compiler errors are fixed automatically.

Generate a plugin

2 free plugins a month, no card.

Last updated Oct 26, 2026.

Get plugins that compile first time

Generate