<commit_before>﻿namespace AngleSharp.DOM.Css
{
    using System;

    /// <summary>
    /// Represents an @namespace rule.
    /// </summary>
    sealed class CSSNamespaceRule : CSSRule, ICssNamespaceRule
    {
        #region Fields

        String _namespaceURI;
        String _prefix;

        #endregion

        #region ctor

        /// <summary>
        /// Creates a new @namespace rule.
        /// </summary>
        internal CSSNamespaceRule()
        {
            _type = CssRuleType.Namespace;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets a string containing the text of the
        /// URI of the given namespace.
        /// </summary>
        public String NamespaceUri
        {
            get { return _namespaceURI; }
            set 
            {
                CheckValidity();
                _namespaceURI = value; 
            }
        }

        /// <summary>
        /// Gets or sets a string with the name of the prefix
        /// associated to this namespace. If there is no such
        /// prefix, returns null.
        /// </summary>
        public String Prefix
        {
            get { return _prefix; }
            set 
            {
                CheckValidity();
                _prefix = value;
            }
        }

        #endregion

        #region Internal Methods

        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CSSNamespaceRule;
            _namespaceURI = newRule._namespaceURI;
            _prefix = newRule._prefix;
        }

        #endregion

        #region Helpers

        void CheckValidity()
        {
            var parent = Owner;
            var list = parent != null ? parent.Rules : null;

            if (list != null)<commit_msg>Treat null as empty string<commit_after>﻿namespace AngleSharp.DOM.Css
{
    using System;

    /// <summary>
    /// Represents an @namespace rule.
    /// </summary>
    sealed class CSSNamespaceRule : CSSRule, ICssNamespaceRule
    {
        #region Fields

        String _namespaceURI;
        String _prefix;

        #endregion

        #region ctor

        /// <summary>
        /// Creates a new @namespace rule.
        /// </summary>
        internal CSSNamespaceRule()
        {
            _type = CssRuleType.Namespace;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets a string containing the text of the
        /// URI of the given namespace.
        /// </summary>
        public String NamespaceUri
        {
            get { return _namespaceURI; }
            set 
            {
                CheckValidity();
                _namespaceURI = value ?? String.Empty;
            }
        }

        /// <summary>
        /// Gets or sets a string with the name of the prefix
        /// associated to this namespace. If there is no such
        /// prefix, returns null.
        /// </summary>
        public String Prefix
        {
            get { return _prefix; }
            set 
            {
                CheckValidity();
                _prefix = value ?? String.Empty;
            }
        }

        #endregion

        #region Internal Methods

        protected override void ReplaceWith(ICssRule rule)
        {
            var newRule = rule as CSSNamespaceRule;
            _namespaceURI = newRule._namespaceURI;
            _prefix = newRule._prefix;
        }

        #endregion

        #region Helpers

        void CheckValidity()
        {
            var parent = Owner;
            var list = parent != null ? parent.Rules : null;

            if (list != null)
{'fraction_non_alphanumeric': 0.08500270709258256, 'fraction_numerical': 0.0, 'mean_word_length': 1.2285886610373944, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5890212', 'n_tokens_mistral': 933, 'n_tokens_neox': 885, 'n_words': 275}