| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolset.ComPlus |
| 4 | { |
| 5 | using System; |
| 6 | using System.Resources; |
| 7 | using WixToolset.Data; |
| 8 | |
| 9 | public static class ComPlusErrors |
| 10 | { |
| 11 | public static Message IllegalAttributeWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName) |
| 12 | { |
| 13 | return Message(sourceLineNumbers, Ids.IllegalAttributeWithoutComponent, "The {0}/@{1} attribute cannot be specified unless the element has a component as an ancestor. A {0} that does not have a component ancestor is not installed.", elementName, attributeName); |
| 14 | } |
| 15 | |
| 16 | public static Message IllegalElementWithoutComponent(SourceLineNumber sourceLineNumbers, string elementName) |
| 17 | { |
| 18 | return Message(sourceLineNumbers, Ids.IllegalElementWithoutComponent, "The {0} element cannot be specified unless the element has a component as an ancestor. A {0} that does not have a component ancestor is not installed.", elementName); |
| 19 | } |
| 20 | |
| 21 | public static Message RequiredAttribute(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2) |
| 22 | { |
| 23 | return Message(sourceLineNumbers, Ids.RequiredAttribute, "A {0} element must have either a {1} attribute or a {2} attribute, or both set.", elementName, attributeName1, attributeName2); |
| 24 | } |
| 25 | |
| 26 | public static Message RequiredAttributeNotUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName1, string attributeName2) |
| 27 | { |
| 28 | return Message(sourceLineNumbers, Ids.RequiredAttributeNotUnderComponent, "A {0} element not nested under a component must have either a {1} attribute or a {2} attribute, or both set.", elementName, attributeName1, attributeName2); |
| 29 | } |
| 30 | |
| 31 | public static Message RequiredAttributeUnderComponent(SourceLineNumber sourceLineNumbers, string elementName, string attributeName) |
| 32 | { |
| 33 | return Message(sourceLineNumbers, Ids.RequiredAttributeUnderComponent, "The {0}/@{1} attribute must be provided when {0} element is nested under a component.", elementName, attributeName); |
| 34 | } |
| 35 | |
| 36 | public static Message UnexpectedAttributeWithOtherValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string otherAttributeName, string otherValue) |
| 37 | { |
| 38 | return Message(sourceLineNumbers, Ids.UnexpectedAttributeWithOtherValue, "The {0}/@{1} attribute cannot coexist with the {2} attribute's value of '{3}'.", elementName, attributeName, otherAttributeName, otherValue); |
| 39 | } |
| 40 | |
| 41 | public static Message UnexpectedAttributeWithOtherValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string value, string otherAttributeName, string otherValue) |
| 42 | { |
| 43 | return Message(sourceLineNumbers, Ids.UnexpectedAttributeWithOtherValue, "The {0}/@{1} attribute's value, '{2}', cannot coexist with the {3} attribute's value of '{4}'.", elementName, attributeName, value, otherAttributeName, otherValue); |
| 44 | } |
| 45 | |
| 46 | public static Message UnexpectedAttributeWithoutOtherValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string otherAttributeName, string otherValue) |
| 47 | { |
| 48 | return Message(sourceLineNumbers, Ids.UnexpectedAttributeWithoutOtherValue, "The {0}/@{1} cannot be provided unless the {2} attribute is provided with a value of '{3}'.", elementName, attributeName, otherAttributeName, otherValue); |
| 49 | } |
| 50 | |
| 51 | private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args) |
| 52 | { |
| 53 | return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args); |
| 54 | } |
| 55 | |
| 56 | private static Message Message(SourceLineNumber sourceLineNumber, Ids id, ResourceManager resourceManager, string resourceName, params object[] args) |
| 57 | { |
| 58 | return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args); |
| 59 | } |
| 60 | |
| 61 | public enum Ids |
| 62 | { |
| 63 | IllegalAttributeWithoutComponent = 6000, |
| 64 | IllegalElementWithoutComponent = 6001, |
| 65 | UnexpectedAttributeWithOtherValue = 6002, |
| 66 | UnexpectedAttributeWithoutOtherValue = 6003, |
| 67 | RequiredAttributeUnderComponent = 6004, |
| 68 | RequiredAttribute = 6005, |
| 69 | RequiredAttributeNotUnderComponent = 6006, |
| 70 | } |
| 71 | } |
| 72 | } |