17 using System.Runtime.CompilerServices;
18 using System.Collections.Generic;
29 public static partial class Messages
39 [MethodImpl(MethodImplOptions.AggressiveInlining)]
42 return $
"{attribute} must be implemented. Please implement this missing method on {pythonType}";
71 [MethodImpl(MethodImplOptions.AggressiveInlining)]
74 return $
"ConvertToDictionary cannot be used to convert a {sourceType} into {targetType}. Reason: {reason}";
87 [MethodImpl(MethodImplOptions.AggressiveInlining)]
88 public static string DuplicateKey(
string duplicateKey,
string type)
90 return $
"More than one '{duplicateKey}' member was found in '{type}' class.";
96 [MethodImpl(MethodImplOptions.AggressiveInlining)]
99 return $
"{key} key does not exist in series dictionary.";
111 public static string Start =
"start";
116 public static string Ended =
"ended";
121 [MethodImpl(MethodImplOptions.AggressiveInlining)]
124 return $
"Unable to find algorithm location path: {algorithmLocation}.";
130 [MethodImpl(MethodImplOptions.AggressiveInlining)]
133 return $
"Path {virtualEnvPath} to virtual environment does not exist.";
139 [MethodImpl(MethodImplOptions.AggressiveInlining)]
142 return $
@"virtual env '{virtualEnvPath}'. Failed to find system packages configuration. ConfigFile.Exits: {
143 configFile.Exists}. Will default to true.";
150 [MethodImpl(MethodImplOptions.AggressiveInlining)]
153 return $
"virtual env '{virtualEnvPath}'. Will use system packages: {includeSystemPackages}";
159 [MethodImpl(MethodImplOptions.AggressiveInlining)]
162 return $
"Unable to find python path: {pythonPath}. Skipping.";
180 [MethodImpl(MethodImplOptions.AggressiveInlining)]
183 return $
@"{interfaceName} must be fully implemented. Please implement these missing methods on {
184 pythonTypeName}: {string.Join(",
", missingMembers)}";
193 [MethodImpl(MethodImplOptions.AggressiveInlining)]
194 public static string InvalidDictionaryValueType(
string pythonMethodName, Type expectedType, PyType actualPyType)
196 return InvalidDictionaryItemType(pythonMethodName, expectedType, actualPyType, isKey:
false);
199 [MethodImpl(MethodImplOptions.AggressiveInlining)]
200 public static string InvalidDictionaryKeyType(
string pythonMethodName, Type expectedType, PyType actualPyType)
202 return InvalidDictionaryItemType(pythonMethodName, expectedType, actualPyType, isKey:
true);
205 [MethodImpl(MethodImplOptions.AggressiveInlining)]
206 public static string InvalidReturnTypeForMethodWithOutParameters(
string pythonMethodName, PyType pyValueType)
208 return $
"Invalid return type from method '{pythonMethodName.ToSnakeCase()}'. Expected a tuple type but was " +
209 $
"'{GetPythonTypeName(pyValueType)}'. The tuple must contain the return value as the first item, " +
210 $
"with the remaining ones being the out parameters.";
213 [MethodImpl(MethodImplOptions.AggressiveInlining)]
214 public static string InvalidReturnTypeTupleSizeForMethodWithOutParameters(
string pythonMethodName,
long expectedSize,
long actualSize)
216 return $
"Invalid return type from method '{pythonMethodName.ToSnakeCase()}'. Expected a tuple with at least " +
217 $
"'{expectedSize}' items but only '{actualSize}' were returned. " +
218 $
"The tuple must contain the return value as the first item, with the remaining ones being the out parameters.";
221 [MethodImpl(MethodImplOptions.AggressiveInlining)]
222 public static string InvalidOutParameterType(
string pythonMethodName,
int index, Type expectedType, PyType actualPyType)
224 return $
"Invalid out parameter type in method '{pythonMethodName.ToSnakeCase()}'. Out parameter in position {index} " +
225 $
"expected type is '{expectedType.Name}' but was '{GetPythonTypeName(actualPyType)}'.";
228 [MethodImpl(MethodImplOptions.AggressiveInlining)]
229 public static string InvalidReturnType(
string pythonName, Type expectedType, PyType actualPyType,
bool isMethod =
true)
231 var message = isMethod
232 ? $
"Invalid return type from method '{pythonName.ToSnakeCase()}'. "
233 : $
"Invalid type for property '{pythonName.ToSnakeCase()}'. ";
234 message += $
"Expected a type convertible to '{expectedType.Name}' but was '{GetPythonTypeName(actualPyType)}'";
238 [MethodImpl(MethodImplOptions.AggressiveInlining)]
239 public static string InvalidIterable(
string pythonMethodName, Type expectedType, PyType actualPyType)
241 return $
"Invalid return type from method '{pythonMethodName.ToSnakeCase()}'. " +
242 $
"Expected an iterable type of '{expectedType.Name}' items but was '{GetPythonTypeName(actualPyType)}'";
245 [MethodImpl(MethodImplOptions.AggressiveInlining)]
246 public static string InvalidMethodIterableItemType(
string pythonMethodName, Type expectedType, PyType actualPyType)
248 return $
"Invalid return type from method '{pythonMethodName.ToSnakeCase()}'. Expected all the items in the iterator to be of type " +
249 $
"'{expectedType.Name}' but found one of type ' {GetPythonTypeName(actualPyType)}'";
252 [MethodImpl(MethodImplOptions.AggressiveInlining)]
253 private static string InvalidDictionaryItemType(
string pythonMethodName, Type expectedType, PyType actualPyType,
bool isKey =
true)
255 return $
"Invalid value type from method or property '{pythonMethodName.ToSnakeCase()}'. " +
256 $
"Expected all the {(isKey ? "keys
" : "values
")} in the dictionary to be of type '{expectedType.Name}' " +
257 $
"but found one of type '{GetPythonTypeName(actualPyType)}'";
260 [MethodImpl(MethodImplOptions.AggressiveInlining)]
261 private static string GetPythonTypeName(PyType pyType)
263 return pyType.Name.Split(
'.').Last();