public Log ( Level messageLevel, string message ) : void | ||
messageLevel | Level | The |
message | string | The message to log. |
return | void |
/// <summary> /// Creates a new <see cref="Task" /> instance for the given XML and /// <see cref="Project" />. /// </summary> /// <param name="taskNode">The XML to initialize the task with.</param> /// <param name="proj">The <see cref="Project" /> that the <see cref="Task" /> belongs to.</param> /// <returns> /// The new <see cref="Task" /> instance. /// </returns> public static Task CreateTask(XmlNode taskNode, Project proj) { if (taskNode == null) { throw new ArgumentNullException("taskNode"); } if (proj == null) { throw new ArgumentNullException("proj"); } string taskName = taskNode.Name; TaskBuilder builder = TaskBuilders[taskName]; if (builder == null) { Location location = proj.LocationMap.GetLocation(taskNode); throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1083"), taskName), location); } Task task = builder.CreateTask(); task.Project = proj; task.NamespaceManager = proj.NamespaceManager; // check whether the task (or its base class) is deprecated ObsoleteAttribute obsoleteAttribute = (ObsoleteAttribute) Attribute.GetCustomAttribute(task.GetType(), typeof(ObsoleteAttribute), true); if (obsoleteAttribute != null) { Location location = proj.LocationMap.GetLocation(taskNode); string obsoleteMessage = string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1086"), taskName, obsoleteAttribute.Message); if (obsoleteAttribute.IsError) { throw new BuildException(obsoleteMessage, location); } else { proj.Log(Level.Warning, "{0} {1}", location, obsoleteMessage); } } return task; }
private static void CheckDeprecation(string functionName, MethodInfo function, Project project) { // check whether the function is deprecated ObsoleteAttribute obsoleteAttribute = (ObsoleteAttribute) Attribute.GetCustomAttribute(function, typeof(ObsoleteAttribute), true); // if function itself is not deprecated, check if its declaring // type is deprecated if (obsoleteAttribute == null) { obsoleteAttribute = (ObsoleteAttribute) Attribute.GetCustomAttribute(function.DeclaringType, typeof(ObsoleteAttribute), true); } if (obsoleteAttribute != null) { string obsoleteMessage = string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1087"), functionName, obsoleteAttribute.Message); if (obsoleteAttribute.IsError) { throw new BuildException(obsoleteMessage, Location.UnknownLocation); } else { project.Log(Level.Warning, "{0}", obsoleteMessage); } } }
public static DataTypeBase CreateDataType(XmlNode elementNode, Project proj) { if (elementNode == null) { throw new ArgumentNullException("elementNode"); } if (proj == null) { throw new ArgumentNullException("proj"); } string dataTypeName = elementNode.Name; DataTypeBaseBuilder builder = DataTypeBuilders[dataTypeName]; if (builder == null) { Location location = proj.LocationMap.GetLocation(elementNode); throw new BuildException(string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1081"), dataTypeName), location); } DataTypeBase element = (DataTypeBase) builder.CreateDataTypeBase(); element.Project = proj; element.NamespaceManager = proj.NamespaceManager; // check whether the type (or its base class) is deprecated ObsoleteAttribute obsoleteAttribute = (ObsoleteAttribute) Attribute.GetCustomAttribute(element.GetType(), typeof(ObsoleteAttribute), true); if (obsoleteAttribute != null) { Location location = proj.LocationMap.GetLocation(elementNode); string obsoleteMessage = string.Format(CultureInfo.InvariantCulture, ResourceUtils.GetString("NA1085"), dataTypeName, obsoleteAttribute.Message); if (obsoleteAttribute.IsError) { throw new BuildException(obsoleteMessage, location); } else { proj.Log(Level.Warning, "{0} {1}", location, obsoleteMessage); } } return element; }