Search Unity

Bug in Unity, Plz help fix

Discussion in 'Getting Started' started by RealRageGaming, Aug 7, 2022.

  1. RealRageGaming

    RealRageGaming

    Joined:
    Aug 7, 2022
    Posts:
    1
    I keep getting the Error Assets\_Editor\UdonSharp\Editor\UdonSharpASTVistor.cs(1,30): error CS0116: A namespace cannot directly contain members such as fields or methods. I'm new to Unity and havent done any coding yet, this is from an external add-on, and I can't understand it. Here is the code for the thing

    using Microsoft.CodeAnalysis; CSharp
    using Microsoft.CodeAnalysis.CSharp;
    using Microsoft.CodeAnalysis.CSharp.Syntax;
    using System.Collections.Generic;
    using System.Linq;
    using System.Reflection;
    using UnityEngine;

    namespace UdonSharp.Compiler
    {
    public class ASTVisitorContext
    {
    public ResolverContext resolverContext;
    private Stack<SymbolTable> symbolTableStack;
    public LabelTable labelTable;
    public AssemblyBuilder uasmBuilder;
    public System.Type behaviourUserType;
    public int behaviourExecutionOrder = 0;
    public List<ClassDefinition> externClassDefinitions;
    public Dictionary<string, FieldDefinition> localFieldDefinitions;
    public BehaviourSyncMode behaviourSyncMode = BehaviourSyncMode.Any;

    public Stack<ExpressionCaptureScope> expressionCaptureStack = new Stack<ExpressionCaptureScope>();

    public List<MethodDefinition> definedMethods;

    public List<PropertyDefinition> definedProperties;
    public Dictionary<string, FieldDefinition> onModifyCallbackFields = new Dictionary<string, FieldDefinition>();

    // Tracking labels for the current function and flow control
    public JumpLabel returnLabel = null;
    public SymbolDefinition returnJumpTarget = null;
    public SymbolDefinition returnSymbol = null;
    public bool isRecursiveMethod = false;
    public int maxMethodFrameSize = 0; // The maximum size for a "stack frame" for a method. This is used to initialize the correct default size of the artificial stack so that we know we only need to double the size of it at most.
    public SymbolDefinition artificalStackSymbol = null;
    public SymbolDefinition stackAddressSymbol = null;
    public bool requiresVRCReturn = false;

    public Stack<JumpLabel> continueLabelStack = new Stack<JumpLabel>();
    public Stack<JumpLabel> breakLabelStack = new Stack<JumpLabel>();

    public SymbolTable topTable { get { return symbolTableStack.Peek(); } }

    public ExpressionCaptureScope topCaptureScope { get { return expressionCaptureStack.Count > 0 ? expressionCaptureStack.Peek() : null; } }

    // Debugging info
    public SyntaxNode currentNode = null;
    public ClassDebugInfo debugInfo = null;
    public bool pauseDebugInfoWrite = false;

    internal Dictionary<(System.Type, BindingFlags), MethodInfo[]> typeMethodCache = new Dictionary<(System.Type, BindingFlags), MethodInfo[]>();
    internal Dictionary<System.Type, SymbolDefinition> enumCastSymbols;

    public ASTVisitorContext(ResolverContext resolver, SymbolTable rootTable, LabelTable labelTableIn, ClassDebugInfo debugInfoIn = null)
    {
    resolverContext = resolver;

    localFieldDefinitions = new Dictionary<string, FieldDefinition>();
    symbolTableStack = new Stack<SymbolTable>();
    symbolTableStack.Push(rootTable);

    //labelTable = new LabelTable();
    labelTable = labelTableIn;

    uasmBuilder = new AssemblyBuilder();

    if (debugInfoIn != null)
    {
    debugInfo = debugInfoIn;
    debugInfo.assemblyBuilder = uasmBuilder;
    }
    }


    public void PushTable(SymbolTable newTable)
    {
    if (newTable.parentSymbolTable != topTable)
    throw new System.ArgumentException("Parent symbol table is not valid for given context.");

    Edit: I'm using Unity version 2019.4.31f1 for this projects
     
    Last edited: Aug 7, 2022
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Your very first line is incorrect, as the message states. It looks like a duplicate of the second line. As a test, just delete that first line. Otherwise, contact the asset developer.