Example #1
0
		void CompareAttributeArguments (ComparisonNode parent, CompAttribute referenceAttribute, CompAttribute actualAttribute)
		{
			// Ignore all parameter differences for some attributes
			switch (referenceAttribute.Name) {
			case "System.Diagnostics.DebuggerDisplayAttribute":
			case "System.Diagnostics.DebuggerTypeProxyAttribute":
			case "System.Runtime.CompilerServices.CompilationRelaxationsAttribute":
			case "System.Reflection.AssemblyFileVersionAttribute":
			case "System.Reflection.AssemblyCompanyAttribute":
			case "System.Reflection.AssemblyCopyrightAttribute":
			case "System.Reflection.AssemblyProductAttribute":
			case "System.Reflection.AssemblyTrademarkAttribute":
			case "System.Reflection.AssemblyInformationalVersionAttribute":
			case "System.Reflection.AssemblyKeyFileAttribute":

			// Don't care about these for now
			case "System.ComponentModel.EditorAttribute":
			case "System.ComponentModel.DesignerAttribute":
				return;
			}

			foreach (var entry in referenceAttribute.Properties) {
				if (!actualAttribute.Properties.ContainsKey (entry.Key)) {

					//
					// Ignore missing value difference for default values
					//
					switch (referenceAttribute.Name) {
					case "System.AttributeUsageAttribute":
						// AllowMultiple defaults to false
						if (entry.Key == "AllowMultiple" && entry.Value == "False")
							continue;
						// Inherited defaults to true
						if (entry.Key == "Inherited" && entry.Value == "True")
							continue;
						break;
					case "System.ObsoleteAttribute":
						if (entry.Key == "IsError" && entry.Value == "False")
							continue;

						if (entry.Key == "Message")
							continue;

						break;
					}

					parent.AddError (String.Format ("Property `{0}' value is not set. Expected value: {1}", entry.Key, entry.Value));
					parent.Status = ComparisonStatus.Error;
					continue;
				}

				var target_value = actualAttribute.Properties[entry.Key];

				switch (referenceAttribute.Name) {
				case "System.Runtime.CompilerServices.TypeForwardedFromAttribute":
					if (entry.Key == "AssemblyFullName")
						target_value = target_value.Replace ("neutral", "Neutral");
					break;
				case "System.Runtime.InteropServices.GuidAttribute":
					if (entry.Key == "Value")
						target_value = target_value.ToUpperInvariant ();
					break;
				case "System.ObsoleteAttribute":
					if (entry.Key == "Message")
						continue;

					break;
				}

				if (target_value != entry.Value) {
					parent.AddError (String.Format ("Expected value `{0}' for attribute property `{1}' but found `{2}'", entry.Value, entry.Key, target_value));
					parent.Status = ComparisonStatus.Error;
				}
			}

			
			if (referenceAttribute.Properties.Count != actualAttribute.Properties.Count) {
				foreach (var entry in actualAttribute.Properties) {
					if (!referenceAttribute.Properties.ContainsKey (entry.Key)) {
						parent.AddError (String.Format ("Property `{0}' should not be set", entry.Key));
						parent.Status = ComparisonStatus.Error;
						break;
					}
				}
			}
			

			return;
		}
        void CompareAttributeArguments(ComparisonNode parent, CompAttribute referenceAttribute, CompAttribute actualAttribute)
        {
            // Ignore all parameter differences for some attributes
            switch (referenceAttribute.Name)
            {
            case "System.Diagnostics.DebuggerDisplayAttribute":
            case "System.Diagnostics.DebuggerTypeProxyAttribute":
            case "System.Runtime.CompilerServices.CompilationRelaxationsAttribute":
            case "System.Reflection.AssemblyFileVersionAttribute":
            case "System.Reflection.AssemblyCompanyAttribute":
            case "System.Reflection.AssemblyCopyrightAttribute":
            case "System.Reflection.AssemblyProductAttribute":
            case "System.Reflection.AssemblyTrademarkAttribute":
            case "System.Reflection.AssemblyInformationalVersionAttribute":
            case "System.Reflection.AssemblyKeyFileAttribute":

            // Don't care about these for now
            case "System.ComponentModel.EditorAttribute":
            case "System.ComponentModel.DesignerAttribute":
                return;
            }

            foreach (var entry in referenceAttribute.Properties)
            {
                if (!actualAttribute.Properties.ContainsKey(entry.Key))
                {
                    //
                    // Ignore missing value difference for default values
                    //
                    switch (referenceAttribute.Name)
                    {
                    case "System.AttributeUsageAttribute":
                        // AllowMultiple defaults to false
                        if (entry.Key == "AllowMultiple" && entry.Value == "False")
                        {
                            continue;
                        }
                        // Inherited defaults to true
                        if (entry.Key == "Inherited" && entry.Value == "True")
                        {
                            continue;
                        }
                        break;

                    case "System.ObsoleteAttribute":
                        if (entry.Key == "IsError" && entry.Value == "False")
                        {
                            continue;
                        }

                        if (entry.Key == "Message")
                        {
                            continue;
                        }

                        break;
                    }

                    parent.AddError(String.Format("Property `{0}' value is not set. Expected value: {1}", entry.Key, entry.Value));
                    parent.Status = ComparisonStatus.Error;
                    continue;
                }

                var target_value = actualAttribute.Properties[entry.Key];

                switch (referenceAttribute.Name)
                {
                case "System.Runtime.CompilerServices.TypeForwardedFromAttribute":
                    if (entry.Key == "AssemblyFullName")
                    {
                        target_value = target_value.Replace("neutral", "Neutral");
                    }
                    break;

                case "System.Runtime.InteropServices.GuidAttribute":
                    if (entry.Key == "Value")
                    {
                        target_value = target_value.ToUpperInvariant();
                    }
                    break;

                case "System.ObsoleteAttribute":
                    if (entry.Key == "Message")
                    {
                        continue;
                    }

                    break;
                }

                if (target_value != entry.Value)
                {
                    parent.AddError(String.Format("Expected value `{0}' for attribute property `{1}' but found `{2}'", entry.Value, entry.Key, target_value));
                    parent.Status = ComparisonStatus.Error;
                }
            }


            if (referenceAttribute.Properties.Count != actualAttribute.Properties.Count)
            {
                foreach (var entry in actualAttribute.Properties)
                {
                    if (!referenceAttribute.Properties.ContainsKey(entry.Key))
                    {
                        parent.AddError(String.Format("Property `{0}' should not be set", entry.Key));
                        parent.Status = ComparisonStatus.Error;
                        break;
                    }
                }
            }


            return;
        }