Beispiel #1
0
            /// <inheritdoc />
            public override string ToString()
            {
                var builder = new StringBuilder();

                builder.AppendLine();
                builder.AppendLine($"    Serialized pips: {PipsSerialized}");
                builder.AppendLine($"    Deserialized pips: {PipsDeserialized}");
                for (int i = 0; i < m_pips.Length; ++i)
                {
                    PipType pipType = (PipType)i;
                    builder.AppendLine($"    {pipType.ToString()}: {m_pips[i]}");
                    if (pipType == PipType.Process)
                    {
                        for (int j = 0; j < m_serviceKinds.Length; ++j)
                        {
                            ServicePipKind servicePipKind = (ServicePipKind)j;
                            if (servicePipKind != ServicePipKind.None)
                            {
                                builder.AppendLine($"        {servicePipKind.ToString()}: {m_serviceKinds[j]}");
                            }
                        }
                    }
                }

                return(builder.ToString());
            }
Beispiel #2
0
        /// <nodoc />
        public ServiceInfo(
            ServicePipKind kind,
            ReadOnlyArray <PipId> servicePipDependencies = default(ReadOnlyArray <PipId>),
            PipId shutdownProcessPipId = default(PipId),
            ReadOnlyArray <PipId> finalizationPipIds = default(ReadOnlyArray <PipId>),
            StringId tagToTrack        = default(StringId),
            StringId displayNameForTag = default(StringId))
        {
            Kind = kind;
            ServicePipDependencies     = servicePipDependencies.IsValid ? servicePipDependencies : ReadOnlyArray <PipId> .Empty;
            ShutdownPipId              = shutdownProcessPipId;
            FinalizationPipIds         = finalizationPipIds.IsValid ? finalizationPipIds : ReadOnlyArray <PipId> .Empty;
            TagToTrack                 = tagToTrack;
            DisplayNameForTrackableTag = displayNameForTag;

            Contract.Assert(ServicePipDependencies.IsValid);
            Contract.Assert(FinalizationPipIds.IsValid);

            Contract.Assert(
                !ShutdownPipId.IsValid || Kind == ServicePipKind.Service,
                "'ShutdownProcessPipId' may only be specified when the pip is a 'Service'");

            Contract.Assert(
                !FinalizationPipIds.Any() || Kind == ServicePipKind.Service,
                "'FinalizationPipids' may only be specified when the pip is a 'Service'");

            // NOTE: The constraint below is not required by the engine, but is enforced here just to
            //       help users out, and catch builds that are *likely* to be errors.  If and when we
            //       encounter a case where a user will want to schedule a shutdown command from their
            //       own build specs (e.g., so that they can have some other pips depend on it), we can
            //       just lift this constraint.
            Contract.Assert(
                Kind != ServicePipKind.Service || ShutdownPipId.IsValid,
                "A pip that is a 'Service' must have the 'ShutdownProcessPipId' specified");

            Contract.Assert(
                ServicePipDependencies.All(pipId => pipId.IsValid),
                "'ServicePipDependencies' must not contain invalid PipIds");

            Contract.Assert(
                Kind != ServicePipKind.ServiceClient || ServicePipDependencies.Any(),
                "A pip that is a 'ServiceClient' must have some 'ServicePipDependencies'");

            Contract.Assert(
                !ServicePipDependencies.Any() || Kind == ServicePipKind.ServiceClient,
                "'ServicePipDependencies' may only be specified for a pip that is either a 'ServiceClient'");

            Contract.Assert(
                TagToTrack.IsValid == DisplayNameForTrackableTag.IsValid,
                "Tag and its display name must be specified at the same time");

            Contract.Assert(
                !TagToTrack.IsValid || Kind == ServicePipKind.Service,
                "'TagToTrack' may only be specified when the pip is a 'Service'");
        }
Beispiel #3
0
        /// <nodoc />
        public ServiceInfo(
            ServicePipKind kind,
            ReadOnlyArray <PipId> servicePipDependencies = default(ReadOnlyArray <PipId>),
            PipId shutdownProcessPipId = default(PipId),
            ReadOnlyArray <PipId> finalizationPipIds = default(ReadOnlyArray <PipId>))
        {
            Kind = kind;
            ServicePipDependencies = servicePipDependencies.IsValid ? servicePipDependencies : ReadOnlyArray <PipId> .Empty;
            ShutdownPipId          = shutdownProcessPipId;
            FinalizationPipIds     = finalizationPipIds.IsValid ? finalizationPipIds : ReadOnlyArray <PipId> .Empty;

            // Calling invariant method explicitely because this is the only way to check it at least once.
            Invariant();
        }
Beispiel #4
0
 /// <summary>
 /// Returns true if <paramref name="kind"/> is either <see cref="ServicePipKind.Service"/>
 /// or <see cref="ServicePipKind.ServiceShutdown"/>.
 /// </summary>
 public static bool IsStartOrShutdown(this ServicePipKind kind)
 {
     return(kind == ServicePipKind.Service || kind == ServicePipKind.ServiceShutdown);
 }