ResolveAliases() public method

Resolves the aliases that could not be resolved while loading the document.
public ResolveAliases ( ) : void
return void
Ejemplo n.º 1
0
		/// <summary>
		/// Initializes a new instance of the <see cref="YamlDocument"/> class.
		/// </summary>
		/// <param name="events">The events.</param>
		internal YamlDocument(EventReader events)
		{
			DocumentLoadingState state = new DocumentLoadingState();

			events.Expect<DocumentStart>();

			while (!events.Accept<DocumentEnd>())
			{
				Debug.Assert(RootNode == null);
				RootNode = YamlNode.ParseNode(events, state);

				if (RootNode is YamlAliasNode)
				{
					throw new YamlException();
				}
			}

			state.ResolveAliases();

#if DEBUG
			foreach (var node in AllNodes)
			{
				if (node is YamlAliasNode)
				{
					throw new InvalidOperationException("Error in alias resolution.");
				}
			}
#endif

			events.Expect<DocumentEnd>();
		}
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="YamlDocument"/> class.
        /// </summary>
        /// <param name="events">The events.</param>
        internal YamlDocument(EventReader events)
        {
            DocumentLoadingState state = new DocumentLoadingState();

            events.Expect <DocumentStart>();

            while (!events.Accept <DocumentEnd>())
            {
                Debug.Assert(RootNode == null);
                RootNode = YamlNode.ParseNode(events, state);

                if (RootNode is YamlAliasNode)
                {
                    throw new YamlException();
                }
            }

            state.ResolveAliases();

#if DEBUG
            foreach (var node in AllNodes)
            {
                if (node is YamlAliasNode)
                {
                    throw new InvalidOperationException("Error in alias resolution.");
                }
            }
#endif

            events.Expect <DocumentEnd>();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="YamlDocument"/> class.
        /// </summary>
#pragma warning disable CS8618 // Non-nullable field is uninitialized. There is a guard that throws an exception if this happens (upstream bug: https://github.com/dotnet/roslyn/issues/44046).
        internal YamlDocument(IParser parser)
#pragma warning restore CS8618 // Non-nullable field is uninitialized.
        {
            var state = new DocumentLoadingState();

            parser.Consume <DocumentStart>();

            while (!parser.TryConsume <DocumentEnd>(out var _))
            {
                Debug.Assert(RootNode == null);
                RootNode = YamlNode.ParseNode(parser, state);

                if (RootNode is YamlAliasNode)
                {
                    throw new YamlException("A document cannot contain only an alias");
                }
            }

            state.ResolveAliases();

            if (RootNode == null)
            {
                // This should not happen unless the parser has a bug
                throw new ArgumentException("Atempted to parse an empty document");
            }
        }
Ejemplo n.º 4
0
        internal YamlDocument(EventReader events)
        {
            DocumentLoadingState state = new DocumentLoadingState();

            events.Expect <DocumentStart>();
            while (!events.Accept <DocumentEnd>())
            {
                this.RootNode = YamlNode.ParseNode(events, state);
                if (this.RootNode is YamlAliasNode)
                {
                    throw new YamlException();
                }
            }
            state.ResolveAliases();
            events.Expect <DocumentEnd>();
        }
Ejemplo n.º 5
0
        internal YamlDocument(IParser parser)
        {
            DocumentLoadingState documentLoadingState = new DocumentLoadingState();

            parser.Expect <DocumentStart>();
            while (!parser.Accept <DocumentEnd>())
            {
                Debug.Assert(RootNode == null);
                RootNode = YamlNode.ParseNode(parser, documentLoadingState);
                if (RootNode is YamlAliasNode)
                {
                    throw new YamlException();
                }
            }
            documentLoadingState.ResolveAliases();
            parser.Expect <DocumentEnd>();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="YamlDocument"/> class.
        /// </summary>
        internal YamlDocument(IParser parser)
        {
            var state = new DocumentLoadingState();

            parser.Expect<DocumentStart>();

            while (!parser.Accept<DocumentEnd>())
            {
                Debug.Assert(RootNode == null);
                RootNode = YamlNode.ParseNode(parser, state);

                if (RootNode is YamlAliasNode)
                {
                    throw new YamlException();
                }
            }

            state.ResolveAliases();

            parser.Expect<DocumentEnd>();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="YamlDocument"/> class.
        /// </summary>
        internal YamlDocument(IParser parser)
        {
            var state = new DocumentLoadingState();

            parser.Consume <DocumentStart>();

            while (!parser.TryConsume <DocumentEnd>(out var _))
            {
                Debug.Assert(RootNode == null);
                RootNode = YamlNode.ParseNode(parser, state);

                if (RootNode is YamlAliasNode)
                {
                    throw new YamlException("A document cannot contain only an alias");
                }
            }

            state.ResolveAliases();

            // Throw should not happen unless the parser has a bug
            RootNode = RootNode ?? throw new ArgumentException("Atempted to parse an empty document");
        }