Handle the implicit auto value for limits now written by the compiler to the xml

This commit is contained in:
Balint-H
2024-03-14 12:38:56 +00:00
parent 069708a599
commit c2bef232b6
3 changed files with 27 additions and 15 deletions
@@ -37,6 +37,28 @@ public static class XmlElementExtensions {
}
}
public static bool GetLimitedAttribute(
this XmlElement element, string name, bool rangeDefined) {
var strValue = element.GetStringAttribute(name, "auto");
if (strValue == "auto" && rangeDefined && element.GetAutolimitsEnabled()) return true;
if (strValue == "auto") return false;
bool parsedValue;
if (bool.TryParse(strValue, out parsedValue)) {
return parsedValue;
} else {
throw new ArgumentException($"'{strValue}' is not a bool.");
}
}
public static bool GetAutolimitsEnabled(
this XmlElement element) {
bool autolimits = (element.OwnerDocument?.GetElementsByTagName("compiler")[0]?["compiler"])
?.GetBoolAttribute("autolimits", true) ??
true;
return autolimits;
}
public static float GetFloatAttribute(
this XmlElement element, string name, float defaultValue = 0.0f) {
if (!element.HasAttribute(name)) {