private string GetMemberStringValue()

in Sharpmake/Resolver.cs [649:754]


        private string GetMemberStringValue(string memberPath, bool throwIfNotFound)
        {
            string[] names = memberPath.Split(s_memberPathSplitter);

            if (names.Length == 0)
            {
                if (throwIfNotFound)
                    throw new NotFoundException("Cannot find unnamed parameter");
                return null;
            }

            PropertyModifier modifier = PropertyModifier.None;
            string parameterName = ExtractNameAndModifier(names[0], out modifier);

            // get the parameters...
            if (!IsCaseSensitive)
                parameterName = parameterName.ToLowerInvariant();
            RefCountedSymbol refCountedReference;
            if (!_parameters.TryGetValue(parameterName, out refCountedReference))
            {
                if (throwIfNotFound)
                    throw new NotFoundException($"Cannot resolve parameter '{parameterName}'.", _parameters.Keys);

                return null;
            }
            object parameter = refCountedReference.Value;

            string name = "";
            for (int i = 1; i < names.Length && parameter != null; ++i)
            {
                bool found = false;

                string nameChunk = names[i];

                Type parameterType = parameter.GetType();
                FieldInfo fieldInfo;
                PropertyInfo propertyInfo;
                GetFieldInfoOrPropertyInfo(parameterType, nameChunk, out fieldInfo, out propertyInfo);

                if (fieldInfo != null)
                {
                    parameter = fieldInfo.GetValue(parameter);
                    found = true;
                }
                else if (propertyInfo != null)
                {
                    parameter = propertyInfo.GetValue(parameter, null);
                    found = true;
                }

                // IDictionary support
                if (!found && i == names.Length - 1 && parameter is IDictionary)
                {
                    var dictionary = parameter as IDictionary;
                    if (dictionary.Contains(nameChunk))
                    {
                        parameter = dictionary[nameChunk];
                        found = true;
                    }
                }

                if (!found)
                {
                    if (throwIfNotFound)
                    {
                        string currentPath = parameterName + name + _pathSeparator;

                        // get all public fields
                        var possibleArguments = parameterType.GetFields().Select(f => currentPath + f.Name);

                        // all public properties
                        possibleArguments = possibleArguments.Concat(parameterType.GetProperties().Select(p => currentPath + p.Name));

                        // and dictionary keys, if they are strings
                        var dictionary = parameter as IDictionary;
                        if (dictionary != null)
                        {
                            var keysAsStrings = ((IDictionary)parameter).Keys as IEnumerable<string>;
                            if (keysAsStrings != null)
                                possibleArguments = possibleArguments.Concat(keysAsStrings.Select(k => currentPath + k));
                        }

                        throw new NotFoundException(
                            $"Cannot find path '{nameChunk}' in parameter path '{memberPath}'",
                            possibleArguments
                        );
                    }
                    return null;
                }

                name += _pathSeparator + nameChunk;
            }

            if (parameter == null)
            {
                throw new NotFoundException(parameterName + name + " is null on target type " + refCountedReference.Value.GetType().Name + ", please set a proper value for sharpmake to resolve it");
            }

            // Handle platform names in case they are provided by a platform extension, this allows "[target.Platform]" to be properly resolved
            if (parameter is Platform platformParameter)
            {
                parameter = Util.GetSimplePlatformString(platformParameter);
            }

            return ApplyModifier(modifier, parameter.ToString());
        }