Exemplo n.º 1
0
        /// <summary>
        /// Creates the setter value.
        /// </summary>
        /// <param name="currNode">The curr node.</param>
        /// <param name="overloadMethods">The overload methods.</param>
        /// <returns>SetterLValue.</returns>
        private SetterLValue createSetterValue(INodeAST currNode, IEnumerable <TypeMethodInfo> overloadMethods)
        {
            var overloads = overloadMethods.ToArray();

            //overloading on setters is not supported
            if (overloads.Length > 1)
            {
                throw CSharpSyntax.ParsingException(currNode, "Cannot select setter overload for {0}", currNode.Value);
            }

            var overload = overloads[0];

            if (!overload.IsStatic && _currentObject == null)
            {
                if (!_compiler.MethodInfo.HasThis)
                {
                    //cannot get implicit this object
                    return(null);
                }

                var implicitThis = _compiler.CreateImplicitThis(currNode);
                setCurrentObject(implicitThis, currNode, true);
            }

            var indexArguments = _compiler.GetArguments(currNode, currNode.Indexer != null);

            return(new SetterLValue(overloads[0], _currentObject, indexArguments, Context));
        }
            public string GetValidatedId(ParsedContracts contracts)
            {
                var id = nameId?.Text ?? nameCtxKw?.GetText() ?? nameKw?.GetText();

                if (string.IsNullOrEmpty(id))
                {
                    return(string.Empty);
                }

                if (CSharpSyntax.IsCSharpKeyword(id) && escape == null)
                {
                    contracts.AddError(this, "'{0}' is a C# keyword and has to be escaped with '@'", id);
                }

                return(id);
            }
 public bool should_validate_namespaces(string value) => CSharpSyntax.IsValidNamespace(value);
 public bool should_validate_identifiers(string value) => CSharpSyntax.IsValidIdentifier(value);