<commit_before>﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;


namespace WLWStaticAnchorManager
{

    public class AnchorData
    {
        private static string rgxOnlyAlphaNumeric = "[^0-9a-zA-Z-_:]";
        private string _anchorID = "";


        public string DisplayText { get; set; }
        public AnchorTypes AnchorClass { get; set; }


        public AnchorData()
        {
            this.AnchorClass = AnchorTypes.None;
            this.AnchorID = "";
            this.DisplayText = "";
        }


        public string AnchorID
        {
            get
            {
                return _anchorID;
            }
            set
            {
                /*
                 * Make sure that only alphanumeric characters and 
                 * allowable separators exist in the ID:
                 */
                var rgx = new Regex(rgxOnlyAlphaNumeric);
                _anchorID = rgx.Replace(value, "-");
            }
        }


        public string LinkReference
        {
            get { return "#" + this._anchorID; }
        }




    }
}<commit_msg>Protected against passing a null value to AnchorData as AnchorID. Threw exception when applying regex to remove whitespace in teh setter.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;


namespace WLWStaticAnchorManager
{

    public class AnchorData
    {
        private static string rgxOnlyAlphaNumeric = "[^0-9a-zA-Z-_:]";
        private string _anchorID = "";


        public string DisplayText { get; set; }
        public AnchorTypes AnchorClass { get; set; }


        public AnchorData()
        {
            this.AnchorClass = AnchorTypes.None;
            this.AnchorID = "";
            this.DisplayText = "";
        }


        public string AnchorID
        {
            get
            {
                return _anchorID;
            }
            set
            {
                /*
                 * Make sure that only alphanumeric characters and 
                 * allowable separators exist in the ID:
                 */
                if (value == null)
                {
                    value = "";
                }
                var rgx = new Regex(rgxOnlyAlphaNumeric);
                _anchorID = rgx.Replace(value, "-");
            }
        }


        public string LinkReference
        {
            get { return "#" + this._anchorID; }
        }




    }
}
{'fraction_non_alphanumeric': 0.08060055314105097, 'fraction_numerical': 0.0015804030027657052, 'mean_word_length': 1.3444444444444446, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2746825', 'n_tokens_mistral': 688, 'n_tokens_neox': 632, 'n_words': 162}