Upgrading from P# to Coyote
This document contains a list of changes from P# to Coyote. Please follow this guide in order to upgrade your applications and services. Contact us if you have any questions or face any issues.
Note: This page is not actively maintained, and changes from P# might have evolved further.
General changes
- Consume the
Microsoft.Coyote
NuGet package, instead of theMicrosoft.PSharp
NuGet package.
Namespace changes
- Rename each
using Microsoft.PSharp.*
toMicrosoft.Coyote.*
. - State machines are now under the new
Microsoft.Coyote.Actors
namespace, to make it explicit that state machines are implementations of the actor programming model. - The
Monitor
type is now under theMicrosoft.Coyote.Specifications
namespace.
Type changes
Machine
was renamed toStateMachine
to make it explicit that its a state machine.MachineState
was renamed toState
, as it is now a nested class insideStateMachine
.MonitorState
was renamed toState
, as it is now a nested class insideMonitor
.MachineId
was renamed toActorId
, as state machines are implementations of the actor programming model.Halt
was renamed toHaltEvent
to make it explicit that its an event.Default
was renamed toDefaultEvent
to make it explicit that its an event.IMachineRuntime
was renamed toIActorRuntime
.IMachineRuntimeLog
was renamed toIActorRuntimeLog
.RuntimeLogWriter
was renamed toActorRuntimeLogWriter
.
Runtime API changes
- The static runtime factory was renamed from
PSharpRuntime
toRuntimeFactory
, so you can now doRuntimeFactory.Create()
to get an actor runtime instance (that can execute state machines). IMachineRuntime.CreateMachine
was renamed toIActorRuntime.CreateActor
.- The previously deprecated method
IMachineRuntime.CreateMachineAndExecute
has been removed, please useIActorRuntime.CreateActorAndExecuteAsync
instead (same semantics, just different method name). - The previously deprecated method
IMachineRuntime.SendEventAndExecute
has been removed, please useIActorRuntime.SendEventAndExecuteAsync
instead (same semantics, just different method name).
Machine API changes
Machine.CreateMachine
was renamedStateMachine.CreateActor
.Machine.Raise
was renamedStateMachine.RaiseEvent
to become more descriptive.Machine.Goto
was renamedStateMachine.RaiseGotoStateEvent
to become more descriptive.Machine.Push
was renamedStateMachine.RaisePushStateEvent
to become more descriptive.Machine.Pop
was renamedStateMachine.RaisePopStateEvent
to become more descriptive.Machine.Receive
was renamedStateMachine.ReceiveEventAsync
to become more descriptive.Machine.Send
was renamedStateMachine.SendEvent
to become more descriptive and match the runtime API.- The
ReceivedEvent
property has been removed. You can now declare event handlers that take a singleEvent
as an in-parameter, which is theEvent
that triggered the handler. A handler that does not require access to thisEvent
can be still declared without an in-parameter. Some of the user callbacks (e.g.OnException
andOnHaltAsync
) now give access to the last dequeued event. - Introduced new API
RaiseHaltEvent
for raising the HaltEvent on yourself (this is more efficient than halting via aRaiseEvent
).
Event API changes
Halt
(nowHaltEvent
) can no longer be constructed, useHaltEvent.Instance
instead to get access to a singleton instance created once to reduce unnecessary allocations.
Monitor API changes
Monitor.Raise
was renamed toMonitor.RaiseEvent
to become more descriptive.- Similar to the
Machine
type,Goto
isRaiseGotoStateEvent
.
Test attribute changes
[Microsoft.PSharp.Test]
was renamed to[Microsoft.Coyote.SystematicTesting.Test]
Command line tool changes
- The
PSharpTester
andPSharpReplayer
executables have now been merged into thecoyote
command line tool. To invoke the tester, you docoyote test ...
. To invoke the replayer you docoyote replay ...
. The command line options remain pretty much the same, but the way they are declared has changed from (for example)-max-steps:100
to--max-steps 100
(single character arguments are used with a single-
, e.g.-i 100
). Read more details in the documentation on using thecoyote
command line tool here.