~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.WebReferences/MonoDevelop.WebReferences/MoonlightChannelBaseExtension.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
179
179
                        // clear IExtensibleDataObject. Since there is *no* way 
180
180
                        // to identify the type of a TypeReference, I cannot do 
181
181
                        // anything but this brutal removal.
182
 
                        foreach (CodeNamespace cns in context.ServiceContractGenerator.TargetCompileUnit.Namespaces)
183
 
                                foreach (CodeTypeDeclaration ct in cns.Types)
184
 
                                        if (ct != ml_context.ClientType && !ct.Name.EndsWith ("EventArgs", StringComparison.Ordinal))
 
182
                        // Also clear ExtensionDataObject members.
 
183
                        foreach (CodeNamespace cns in context.ServiceContractGenerator.TargetCompileUnit.Namespaces) {
 
184
                                foreach (CodeTypeDeclaration ct in cns.Types) {
 
185
                                        if (!ShouldPreserveBaseTypes (ct))
185
186
                                                ct.BaseTypes.Clear ();
 
187
                                        CodeTypeMember cp = null, cf = null;
 
188
                                        foreach (CodeTypeMember cm in ct.Members) {
 
189
                                                if (cm is CodeMemberProperty && cm.Name == "ExtensionData")
 
190
                                                        cp = cm;
 
191
                                                else if (cm is CodeMemberField && cm.Name == "extensionDataField")
 
192
                                                        cf = cm;
 
193
                                        }
 
194
                                        if (cf != null)
 
195
                                                ct.Members.Remove (cf);
 
196
                                        if (cp != null)
 
197
                                                ct.Members.Remove (cp);
 
198
                                }
 
199
                        }
 
200
                }
 
201
 
 
202
                bool ShouldPreserveBaseTypes (CodeTypeDeclaration ct)
 
203
                {
 
204
                        foreach (CodeTypeReference cr in ct.BaseTypes) {
 
205
                                if (cr.BaseType == "System.ServiceModel.ClientBase`1")
 
206
                                        return true;
 
207
                                if (cr.BaseType == "System.ComponentModel.AsyncCompletedEventArgs")
 
208
                                        return true;
 
209
                        }
 
210
                        return false;
186
211
                }
187
212
 
188
213
                void EliminateSync ()
316
341
                                        | MemberAttributes.Final;
317
342
 
318
343
                        var inArgs = new List<CodeParameterDeclarationExpression > ();
 
344
                        var outArgs = new List<CodeParameterDeclarationExpression > ();
319
345
 
320
346
                        foreach (CodeParameterDeclarationExpression p in context.SyncMethod.Parameters) {
321
347
                                inArgs.Add (p);
397
423
                                new CodeArrayCreateExpression (typeof (object), new CodePrimitiveExpression (outArgs.Count)));
398
424
                        cm.Statements.Add (argsDecl);
399
425
 
400
 
                        var cast = new CodeCastExpression (
401
 
                                context.EndMethod.ReturnType,
402
 
                                new CodeMethodInvokeExpression (
 
426
                        var ret = new CodeMethodInvokeExpression (
403
427
                                baseExpr,
404
428
                                "EndInvoke",
405
429
                                new CodePrimitiveExpression (od.Name),
406
430
                                new CodeVariableReferenceExpression ("args"),
407
 
                                new CodeArgumentReferenceExpression (resultArgName)));
408
 
 
 
431
                                new CodeArgumentReferenceExpression (resultArgName));
409
432
                        if (cm.ReturnType.BaseType == "System.Void")
410
 
                                cm.Statements.Add (new CodeExpressionStatement (cast));
 
433
                                cm.Statements.Add (new CodeExpressionStatement (ret));
411
434
                        else
412
 
                                cm.Statements.Add (new CodeMethodReturnStatement (cast));
 
435
                                cm.Statements.Add (new CodeMethodReturnStatement (new CodeCastExpression (context.EndMethod.ReturnType, ret)));
413
436
                }
414
437
 
415
438
                void AddMethodParam (CodeMemberMethod cm, Type type, string name)