Merge pull request #2832 from razzfazz/handle_eintr
[mono.git] / mcs / class / System.Web.Services / System.Web.Services.Description / BasicProfileChecker.cs
index 57c4add63507ad52ab7bdb2718ccec27da63ee85..c0cdcf4c1b8900b9f65d53a877c6b3439bfe0bf3 100644 (file)
@@ -29,8 +29,8 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
 
+using System.IO;
 using System.Xml.Schema;
 using System.Xml.Serialization;
 using System.Xml;
@@ -46,6 +46,15 @@ namespace System.Web.Services.Description
                        get { return WsiProfiles.BasicProfile1_1; }
                }
                
+               /*
+               private string GetAbsoluteUri (string baseUri, string relativeUri)
+               {
+                       string actualBaseUri = baseUri ?? Path.GetFullPath (".") + Path.DirectorySeparatorChar;
+                       Uri uri = new Uri (new Uri (actualBaseUri), relativeUri);
+                       return uri.ToString ();
+               }
+               */
+
                public override void Check (ConformanceCheckContext ctx, Import value) 
                {
                        if (value.Location == "" || value.Location == null) {
@@ -55,9 +64,13 @@ namespace System.Web.Services.Description
                        
                        if (!new Uri (value.Namespace, UriKind.RelativeOrAbsolute).IsAbsoluteUri)
                                ctx.ReportRuleViolation (value, BasicProfileRules.R2803);
-                       
-                       object doc = ctx.GetDocument (value.Location);
-                       if (doc == null) ctx.ReportError (value, "Document '" + value.Location + "' not found");
+
+                       // LAMESPEC: RetrievalUrl does not seem to help here (in .NET)
+                       //ServiceDescription importer = value.ServiceDescription;
+                       //string absUri = GetAbsoluteUri (importer != null ? importer.RetrievalUrl : null, value.Location);
+                       object doc = ctx.GetDocument (/*absUri*/value.Location, value.Namespace);
+                       if (doc == null) // and looks like .net ignores non-resolvable documentation... I dunno if it makes sense. I don't care :/
+                               return; //ctx.ReportError (value, "Document '" + value.Location + "' not found");
                        
                        if (doc is XmlSchema)
                                ctx.ReportRuleViolation (value, BasicProfileRules.R2002);
@@ -128,7 +141,7 @@ namespace System.Web.Services.Description
 
                public override void Check (ConformanceCheckContext ctx, BindingCollection value) {
                        foreach (Binding b in value)
-                               foreach (ServiceDescriptionFormatExtension ext in b.Extensions)
+                               foreach (object ext in b.Extensions)
                                        if (ext.GetType () == typeof (SoapBinding))
                                                return;
 
@@ -163,7 +176,7 @@ namespace System.Web.Services.Description
                                foreach (OperationMessage om in op.Messages) {
                                        Message msg = ctx.Services.GetMessage (om.Message);
                                        foreach (MessagePart part in msg.Parts)
-                                               parts.Add (part,part);
+                                               parts [part] = part; // do not use Add() - there could be the same MessagePart instance.
                                }
                        }
                        
@@ -401,23 +414,25 @@ namespace System.Web.Services.Description
                void CheckR2305 (ConformanceCheckContext ctx, Operation value)
                {
                        string [] order = value.ParameterOrder;
-                       if (order == null || order.Length == 0)
-                               return;
-                       bool omitted = false;
-                       bool violation = false;
-                       for (int i = 0; i < value.Messages.Count; i++) {
-                               OperationMessage msg = value.Messages [i];
-                               if (msg.Name == null) {
-                                       if (omitted)
-                                               violation = true;
-                                       else
-                                               omitted = true;
+                       ServiceDescription sd = value.PortType.ServiceDescription;
+                       Message omitted = null;
+                       foreach (OperationMessage m in value.Messages) {
+                               if (m.Name == null)
+                                       continue; // it is doubtful, but R2305 is not to check such cases anyways.
+                               Message msg = sd.Messages [m.Name];
+                               if (msg == null)
+                                       continue; // it is doubtful, but R2305 is not to check such cases anyways.
+                               foreach (MessagePart p in msg.Parts) {
+                                       if (order != null && Array.IndexOf (order, p.Name) >= 0)
+                                               continue;
+                                       if (omitted == null) {
+                                               omitted = msg;
+                                               continue;
+                                       }
+                                       ctx.ReportRuleViolation (value, BasicProfileRules.R2305);
+                                       return;
                                }
-                               else if (order [omitted ? i - 1 : i] != msg.Name)
-                                       violation = true;
                        }
-                       if (violation)
-                               ctx.ReportRuleViolation (value, BasicProfileRules.R2305);
                }
 
                public override void Check (ConformanceCheckContext ctx, OperationMessage value) { }
@@ -449,7 +464,8 @@ namespace System.Web.Services.Description
                
                public override void Check (ConformanceCheckContext ctx, XmlSchemaImport value)
                {
-                       XmlSchema doc = ctx.GetDocument (value.SchemaLocation) as XmlSchema;
+                       // LAMESPEC: same here to Check() for Import.
+                       XmlSchema doc = ctx.GetDocument (value.SchemaLocation, value.Namespace) as XmlSchema;
                        if (doc == null) ctx.ReportError (value, "Schema '" + value.SchemaLocation + "' not found");
                }
                
@@ -939,4 +955,3 @@ namespace System.Web.Services.Description
        }
 }
 
-#endif