Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Public OperationDescription.Begin/End/SyncMethod properties and add unit test #5165

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,28 @@ public interface IDescriptionTestsServiceGenerated
System.Threading.Tasks.Task<string> EchoAsync(string message);
}

// Dummy interface used for ContractDescriptionTests
// This code is deliberately not cleaned up after svcutil to test that we work with the raw Add Service Reference code.
[System.ServiceModel.ServiceContractAttribute(ConfigurationName = "IDescriptionTestsService")]
public interface IDescriptionTestsServiceBeginEndGenerated
{
[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IDescriptionTestsService/MessageRequestReply", ReplyAction = "http://tempuri.org/IDescriptionTestsService/MessageRequestReplyResponse")]
System.ServiceModel.Channels.Message MessageRequestReply(System.ServiceModel.Channels.Message request);

[System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "http://tempuri.org/IDescriptionTestsService/MessageRequestReply", ReplyAction = "http://tempuri.org/IDescriptionTestsService/MessageRequestReplyResponse")]
System.IAsyncResult BeginMessageRequestReply(System.ServiceModel.Channels.Message request, System.AsyncCallback callback, object asyncState);

System.ServiceModel.Channels.Message EndMessageRequestReply(System.IAsyncResult result);

[System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IDescriptionTestsService/Echo", ReplyAction = "http://tempuri.org/IDescriptionTestsService/EchoResponse")]
string Echo(string message);

[System.ServiceModel.OperationContractAttribute(AsyncPattern = true, Action = "http://tempuri.org/IDescriptionTestsService/Echo", ReplyAction = "http://tempuri.org/IDescriptionTestsService/EchoResponse")]
System.IAsyncResult BeginEcho(string message, System.AsyncCallback callback, object asyncState);

string EndEcho(System.IAsyncResult result);
}

// Manually constructed service interface to validate MessageContract operations.
// This interface closely matches the one found at http://app.thefreedictionary.com/w8feedback.asmx
// This was done to test that we would work with that real world app.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1755,6 +1755,9 @@ public OperationDescription(string name, System.ServiceModel.Description.Contrac
public string Name { get { return default; } }
public System.Collections.ObjectModel.KeyedCollection<System.Type, System.ServiceModel.Description.IOperationBehavior> OperationBehaviors { get { return default; } }
public System.Reflection.MethodInfo TaskMethod { get { return default; } set { } }
public System.Reflection.MethodInfo BeginMethod { get { return default; } set { } }
public System.Reflection.MethodInfo EndMethod { get { return default; } set { } }
public System.Reflection.MethodInfo SyncMethod { get { return default; } set { } }
}
public partial class OperationDescriptionCollection : System.Collections.ObjectModel.Collection<System.ServiceModel.Description.OperationDescription>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,41 @@ public static void ContractDescription_GetContract()
Assert.Equal(typeof(IDescriptionTestsService).Name, contractDescription.ContractType.Name);
Assert.Equal("http://tempuri.org/", contractDescription.Namespace);
}

[WcfFact]
public static void OperationDescription_BeginEndSyncMethod_Property()
{
ContractDescription contractDescription = ContractDescription.GetContract(typeof(IDescriptionTestsServiceBeginEndGenerated));
Assert.Equal(2, contractDescription.Operations.Count);
foreach(OperationDescription operation in contractDescription.Operations)
{
Assert.NotNull(operation.BeginMethod);
Assert.NotNull(operation.EndMethod);
if(operation.Name.Equals("Echo"))
{
Assert.Equal(typeof(IDescriptionTestsServiceBeginEndGenerated).GetMethod(nameof(IDescriptionTestsServiceBeginEndGenerated.BeginEcho)), operation.BeginMethod);
Assert.Equal(typeof(IDescriptionTestsServiceBeginEndGenerated).GetMethod(nameof(IDescriptionTestsServiceBeginEndGenerated.EndEcho)), operation.EndMethod);
}
else
{
Assert.Equal(typeof(IDescriptionTestsServiceBeginEndGenerated).GetMethod(nameof(IDescriptionTestsServiceBeginEndGenerated.BeginMessageRequestReply)), operation.BeginMethod);
Assert.Equal(typeof(IDescriptionTestsServiceBeginEndGenerated).GetMethod(nameof(IDescriptionTestsServiceBeginEndGenerated.EndMessageRequestReply)), operation.EndMethod);
}
}

contractDescription = ContractDescription.GetContract(typeof(IDescriptionTestsService));
Assert.Equal(2, contractDescription.Operations.Count);
foreach (OperationDescription operation in contractDescription.Operations)
{
Assert.NotNull(operation.SyncMethod);
if (operation.Name.Equals("Echo"))
{
Assert.Equal(typeof(IDescriptionTestsService).GetMethod(nameof(IDescriptionTestsService.Echo)), operation.SyncMethod);
}
else
{
Assert.Equal(typeof(IDescriptionTestsService).GetMethod(nameof(IDescriptionTestsService.MessageRequestReply)), operation.SyncMethod);
}
}
}
}