Пример #1
0
        public NamedTypeDetails(IdentifierDetails name, ImmutableList <GenericTypeParameterDetails> genericTypeParams)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (genericTypeParams == null)
            {
                throw new ArgumentNullException(nameof(genericTypeParams));
            }
            if (genericTypeParams.Any(t => t == null))
            {
                throw new ArgumentException("Null reference encountered in set", nameof(genericTypeParams));
            }

            Name = name;
            GenericTypeParams = genericTypeParams;

            var endOfContent = genericTypeParams.Any()
                ? genericTypeParams.Max(t => t.SourceRange.StartIndex + t.SourceRange.Length)
                : (name.SourceRange.StartIndex + name.SourceRange.Length);

            SourceRange = new SourceRangeDetails(
                name.SourceRange.StartIndex,
                endOfContent - name.SourceRange.StartIndex
                );
        }
Пример #2
0
        public TypeDescriptionDetails(string value, SourceRangeDetails sourceRange)
        {
            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentException("may not be null or blank", nameof(value));
            }
            if (sourceRange == null)
            {
                throw new ArgumentNullException(nameof(sourceRange));
            }

            Value       = value; // TODO: Need some more validity checks here
            SourceRange = sourceRange;
        }
        public InterfaceDetails(
            IdentifierDetails name,
            ImmutableList <GenericTypeParameterDetails> genericTypeParams,
            ImmutableList <NamedTypeDetails> baseTypes,
            ImmutableList <PropertyDetails> contents,
            SourceRangeDetails source)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (genericTypeParams == null)
            {
                throw new ArgumentNullException(nameof(genericTypeParams));
            }
            if (genericTypeParams.Any(t => t == null))
            {
                throw new ArgumentException("Null reference encountered in set", nameof(genericTypeParams));
            }
            if (baseTypes == null)
            {
                throw new ArgumentNullException(nameof(baseTypes));
            }
            if (baseTypes.Any(t => t == null))
            {
                throw new ArgumentException("Null reference encountered in set", nameof(baseTypes));
            }
            if (contents == null)
            {
                throw new ArgumentNullException(nameof(contents));
            }
            if (contents.Any(p => p == null))
            {
                throw new ArgumentException("Null reference encountered in set", nameof(contents));
            }
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            Name = name;
            GenericTypeParams = genericTypeParams;
            BaseTypes         = baseTypes;
            Contents          = contents;
            SourceRange       = source;
        }
        public PropertyDetails(IdentifierDetails name, TypeDescriptionDetails type)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            Name = name;
            Type = type;

            SourceRange = new SourceRangeDetails(
                name.SourceRange.StartIndex,
                (type.SourceRange.StartIndex + type.SourceRange.Length) - name.SourceRange.StartIndex
                );
        }
        public GenericTypeParameterDetails(NamedTypeDetails name, Optional <NamedTypeDetails> typeConstraint)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            Name           = name;
            TypeConstraint = typeConstraint;

            var endOfContent = typeConstraint.IsDefined
                ? (typeConstraint.Value.SourceRange.StartIndex + typeConstraint.Value.SourceRange.Length)
                : (name.SourceRange.StartIndex + name.SourceRange.Length);

            SourceRange = new SourceRangeDetails(
                name.SourceRange.StartIndex,
                endOfContent - name.SourceRange.StartIndex
                );
        }
Пример #6
0
        public IdentifierDetails(string value, SourceRangeDetails sourceRange)
        {
            if (string.IsNullOrEmpty(value))
            {
                throw new ArgumentException("may not be null or blank", nameof(value));
            }
            if (sourceRange == null)
            {
                throw new ArgumentNullException(nameof(sourceRange));
            }

            var firstDisallowedCharacter = value
                                           .Select((c, i) => new { Index = i, Character = c })
                                           .FirstOrDefault(indexedCharacter => DisallowedCharacters.Contains(indexedCharacter.Character));

            if (firstDisallowedCharacter != null)
            {
                throw new ArgumentException($"Contains invalid character at index {firstDisallowedCharacter.Index}: '{firstDisallowedCharacter.Character}'", nameof(value));
            }

            Value       = value;
            SourceRange = sourceRange;
        }