Ejemplo n.º 1
0
        private static void UpdateActiveLaunchProfile(IWritableLaunchProfile activeProfile, string propertyName, string unevaluatedPropertyValue)
        {
            switch (propertyName)
            {
            case AuthenticationModePropertyName:
                TrySetOtherProperty(activeProfile, LaunchProfileExtensions.RemoteAuthenticationModeProperty, unevaluatedPropertyValue, string.Empty);
                break;

            case NativeDebuggingPropertyName:
                TrySetOtherProperty(activeProfile, LaunchProfileExtensions.NativeDebuggingProperty, bool.Parse(unevaluatedPropertyValue), false);
                break;

            case RemoteDebugEnabledPropertyName:
                TrySetOtherProperty(activeProfile, LaunchProfileExtensions.RemoteDebugEnabledProperty, bool.Parse(unevaluatedPropertyValue), false);
                break;

            case RemoteDebugMachinePropertyName:
                TrySetOtherProperty(activeProfile, LaunchProfileExtensions.RemoteDebugMachineProperty, unevaluatedPropertyValue, string.Empty);
                break;

            case SqlDebuggingPropertyName:
                TrySetOtherProperty(activeProfile, LaunchProfileExtensions.SqlDebuggingProperty, bool.Parse(unevaluatedPropertyValue), false);
                break;

            default:
                throw new InvalidOperationException($"{nameof(ActiveLaunchProfileExtensionValueProvider)} does not handle property '{propertyName}'.");
            }
        }
Ejemplo n.º 2
0
        private static void UpdateActiveLaunchProfile(IWritableLaunchProfile activeProfile, string propertyName, string newValue)
        {
            switch (propertyName)
            {
            case CommandLineArgumentsPropertyName:
                activeProfile.CommandLineArgs = newValue;
                break;

            case ExecutablePathPropertyName:
                activeProfile.ExecutablePath = newValue;
                break;

            case LaunchBrowserPropertyName:
                activeProfile.LaunchBrowser = bool.Parse(newValue);
                break;

            case LaunchTargetPropertyName:
                activeProfile.CommandName = newValue;
                break;

            case LaunchUrlPropertyName:
                activeProfile.LaunchUrl = newValue;
                break;

            case WorkingDirectoryPropertyName:
                activeProfile.WorkingDirectory = newValue;
                break;

            default:
                throw new InvalidOperationException($"{nameof(ActiveLaunchProfileCommonValueProvider)} does not handle property '{propertyName}'.");
            }
        }
Ejemplo n.º 3
0
        private void SetEnvironmentGrid(IWritableLaunchProfile oldProfile)
        {
            if (EnvironmentVariables != null && oldProfile != null)
            {
                if (_environmentVariables.Count > 0)
                {
                    oldProfile.EnvironmentVariables.Clear();
                    foreach (NameValuePair kvp in EnvironmentVariables)
                    {
                        oldProfile.EnvironmentVariables.Add(kvp.Name, kvp.Value);
                    }
                }
                else
                {
                    oldProfile.EnvironmentVariables.Clear();
                }
                EnvironmentVariables.ValidationStatusChanged -= EnvironmentVariables_ValidationStatusChanged;
                EnvironmentVariables.CollectionChanged       -= EnvironmentVariables_CollectionChanged;
                ((INotifyPropertyChanged)EnvironmentVariables).PropertyChanged -= DebugPageViewModel_EnvironmentVariables_PropertyChanged;
            }

            if (SelectedDebugProfile != null)
            {
                EnvironmentVariables = SelectedDebugProfile.EnvironmentVariables.CreateList();
            }
            else
            {
                EnvironmentVariables = new ObservableList <NameValuePair>();
            }
            EnvironmentVariables.ValidationStatusChanged += EnvironmentVariables_ValidationStatusChanged;
            EnvironmentVariables.CollectionChanged       += EnvironmentVariables_CollectionChanged;
            ((INotifyPropertyChanged)EnvironmentVariables).PropertyChanged += DebugPageViewModel_EnvironmentVariables_PropertyChanged;
        }
        public void OnSetPropertyValue(string propertyName, string propertyValue, IWritableLaunchProfile launchProfile, ImmutableDictionary <string, object> globalSettings, Rule?rule)
        {
            switch (propertyName)
            {
            case AuthenticationModePropertyName:
                TrySetOtherProperty(launchProfile, LaunchProfileExtensions.RemoteAuthenticationModeProperty, propertyValue, string.Empty);
                break;

            case NativeDebuggingPropertyName:
                TrySetOtherProperty(launchProfile, LaunchProfileExtensions.NativeDebuggingProperty, bool.Parse(propertyValue), false);
                break;

            case RemoteDebugEnabledPropertyName:
                TrySetOtherProperty(launchProfile, LaunchProfileExtensions.RemoteDebugEnabledProperty, bool.Parse(propertyValue), false);
                break;

            case RemoteDebugMachinePropertyName:
                TrySetOtherProperty(launchProfile, LaunchProfileExtensions.RemoteDebugMachineProperty, propertyValue, string.Empty);
                break;

            case SqlDebuggingPropertyName:
                TrySetOtherProperty(launchProfile, LaunchProfileExtensions.SqlDebuggingProperty, bool.Parse(propertyValue), false);
                break;

            default:
                throw new InvalidOperationException($"{nameof(ProjectLaunchProfileExtensionValueProvider)} does not handle property '{propertyName}'.");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Compares two IWritableLaunchProfile to see if they contain the same values.
        /// </summary>
        public static bool ProfilesAreEqual(IWritableLaunchProfile debugProfile1, IWritableLaunchProfile debugProfile2)
        {
            // Same instance are equal
            if (debugProfile1 == debugProfile2)
            {
                return(true);
            }

            if (!string.Equals(debugProfile1.Name, debugProfile2.Name, StringComparison.Ordinal) ||
                !string.Equals(debugProfile1.CommandName, debugProfile2.CommandName, StringComparison.Ordinal) ||
                !string.Equals(debugProfile1.ExecutablePath, debugProfile2.ExecutablePath, StringComparison.Ordinal) ||
                !string.Equals(debugProfile1.CommandLineArgs, debugProfile2.CommandLineArgs, StringComparison.Ordinal) ||
                !string.Equals(debugProfile1.WorkingDirectory, debugProfile2.WorkingDirectory, StringComparison.Ordinal) ||
                !string.Equals(debugProfile1.LaunchUrl, debugProfile2.LaunchUrl, StringComparison.Ordinal) ||
                debugProfile1.LaunchBrowser != debugProfile2.LaunchBrowser ||
                !DictionaryEqualityComparer <string, object> .Instance.Equals(debugProfile1.OtherSettings.ToImmutableDictionary(), debugProfile2.OtherSettings.ToImmutableDictionary()) ||
                !DictionaryEqualityComparer <string, string> .Instance.Equals(debugProfile1.EnvironmentVariables.ToImmutableDictionary(), debugProfile2.EnvironmentVariables.ToImmutableDictionary())
                )
            {
                return(false);
            }

            // Compare in-memory states
            return(debugProfile1.IsInMemoryObject() == debugProfile2.IsInMemoryObject());
        }
Ejemplo n.º 6
0
        protected virtual void NotifySelectedChanged(IWritableLaunchProfile oldProfile)
        {
            // we need to keep the property page control from setting IsDirty when we are just switching between profiles.
            // we still need to notify the display of the changes though
            PushIgnoreEvents();
            try
            {
                // these have no backing store in the viewmodel, we need to send notifications when we change selected profiles
                // consider a better way of doing this
                OnPropertyChanged(nameof(SelectedDebugProfile));
                OnPropertyChanged(nameof(CommandLineArguments));
                OnPropertyChanged(nameof(ExecutablePath));
                OnPropertyChanged(nameof(LaunchPage));
                OnPropertyChanged(nameof(HasLaunchOption));
                OnPropertyChanged(nameof(NativeCodeDebugging));
                OnPropertyChanged(nameof(WorkingDirectory));

                UpdateLaunchTypes();

                ActiveProvider?.ProfileSelected(CurrentLaunchSettings);

                OnPropertyChanged(nameof(IsProfileSelected));
                OnPropertyChanged(nameof(DeleteProfileEnabled));

                SetEnvironmentGrid(oldProfile);

                UpdateActiveProfile();
            }
            finally
            {
                PopIgnoreEvents();
            }
        }
Ejemplo n.º 7
0
        public void IsInMemoryProfile_IWritableLaunchProfile(bool isInMemory)
        {
            WritableLaunchProfile data = new WritableLaunchProfile()
            {
                DoNotPersist = isInMemory
            };

            IWritableLaunchProfile lp = (IWritableLaunchProfile)data;

            Assert.Equal(isInMemory, lp.IsInMemoryObject());
        }
 private static void UpdateActiveLaunchProfile(IWritableLaunchProfile activeProfile, string propertyName, string unevaluatedPropertyValue)
 {
     // TODO: Should the result (success or failure) be ignored?
     _ = propertyName switch
     {
         AuthenticationModePropertyName => TrySetOtherProperty(activeProfile, LaunchProfileExtensions.RemoteAuthenticationModeProperty, unevaluatedPropertyValue, string.Empty),
         NativeDebuggingPropertyName => TrySetOtherProperty(activeProfile, LaunchProfileExtensions.NativeDebuggingProperty, bool.Parse(unevaluatedPropertyValue), false),
         RemoteDebugEnabledPropertyName => TrySetOtherProperty(activeProfile, LaunchProfileExtensions.RemoteDebugEnabledProperty, bool.Parse(unevaluatedPropertyValue), false),
         RemoteDebugMachinePropertyName => TrySetOtherProperty(activeProfile, LaunchProfileExtensions.RemoteDebugMachineProperty, unevaluatedPropertyValue, string.Empty),
         SqlDebuggingPropertyName => TrySetOtherProperty(activeProfile, LaunchProfileExtensions.SqlDebuggingProperty, bool.Parse(unevaluatedPropertyValue), false),
         _ => throw new InvalidOperationException($"{nameof(ActiveLaunchProfileExtensionValueProvider)} does not handle property '{propertyName}'."),
     };
 }
        private static bool TrySetOtherProperty <T>(IWritableLaunchProfile launchProfile, string propertyName, T value, T defaultValue) where T : notnull
        {
            if (!launchProfile.OtherSettings.TryGetValue(propertyName, out object current))
            {
                current = defaultValue;
            }

            if (current is not T currentTyped || !Equals(currentTyped, value))
            {
                launchProfile.OtherSettings[propertyName] = value;
                return(true);
            }

            return(false);
        }
 public void OnSetPropertyValue(string propertyName, string propertyValue, IWritableLaunchProfile launchProfile, ImmutableDictionary <string, object> globalSettings, Rule?rule)
 {
     // TODO: Should the result (success or failure) be ignored?
     _ = propertyName switch
     {
         AuthenticationModePropertyName => TrySetOtherProperty(launchProfile, LaunchProfileExtensions.RemoteAuthenticationModeProperty, propertyValue, string.Empty),
         HotReloadEnabledPropertyName => TrySetOtherProperty(launchProfile, LaunchProfileExtensions.HotReloadEnabledProperty, bool.Parse(propertyValue), true),
         NativeDebuggingPropertyName => TrySetOtherProperty(launchProfile, LaunchProfileExtensions.NativeDebuggingProperty, bool.Parse(propertyValue), false),
         RemoteDebugEnabledPropertyName => TrySetOtherProperty(launchProfile, LaunchProfileExtensions.RemoteDebugEnabledProperty, bool.Parse(propertyValue), false),
         RemoteDebugMachinePropertyName => TrySetOtherProperty(launchProfile, LaunchProfileExtensions.RemoteDebugMachineProperty, propertyValue, string.Empty),
         SqlDebuggingPropertyName => TrySetOtherProperty(launchProfile, LaunchProfileExtensions.SqlDebuggingProperty, bool.Parse(propertyValue), false),
         WebView2DebuggingPropertyName => TrySetOtherProperty(launchProfile, LaunchProfileExtensions.JSWebView2DebuggingProperty, bool.Parse(propertyValue), false),
         _ => throw new InvalidOperationException($"{nameof(ProjectLaunchProfileExtensionValueProvider)} does not handle property '{propertyName}'."),
     };
 }
Ejemplo n.º 11
0
        public LaunchProfile(IWritableLaunchProfile writableProfile)
        {
            Name             = writableProfile.Name;
            ExecutablePath   = writableProfile.ExecutablePath;
            CommandName      = writableProfile.CommandName;
            CommandLineArgs  = writableProfile.CommandLineArgs;
            WorkingDirectory = writableProfile.WorkingDirectory;
            LaunchBrowser    = writableProfile.LaunchBrowser;
            LaunchUrl        = writableProfile.LaunchUrl;
            DoNotPersist     = writableProfile.IsInMemoryObject();

            // If there are no env variables or settings we want to set them to null
            EnvironmentVariables = writableProfile.EnvironmentVariables.Count == 0 ? null : writableProfile.EnvironmentVariables.ToImmutableDictionary();
            OtherSettings        = writableProfile.OtherSettings.Count == 0 ? null : writableProfile.OtherSettings.ToImmutableDictionary();
        }
Ejemplo n.º 12
0
        public LaunchProfile(IWritableLaunchProfile writableProfile)
        {
            Name             = writableProfile.Name;
            ExecutablePath   = writableProfile.ExecutablePath;
            CommandName      = writableProfile.CommandName;
            CommandLineArgs  = writableProfile.CommandLineArgs;
            WorkingDirectory = writableProfile.WorkingDirectory;
            LaunchBrowser    = writableProfile.LaunchBrowser;
            LaunchUrl        = writableProfile.LaunchUrl;

            // If there are no env variables or settings we want to set them to null
            EnvironmentVariables = writableProfile.EnvironmentVariables.Count == 0? null : ImmutableDictionary <string, string> .Empty.AddRange(writableProfile.EnvironmentVariables);

            OtherSettings = writableProfile.OtherSettings.Count == 0? null : ImmutableDictionary <string, object> .Empty.AddRange(writableProfile.OtherSettings);
        }
Ejemplo n.º 13
0
        public void WriteProjectForLaunch(IWritableLaunchProfile profile, UnconfiguredProject targetProject)
        {
            if (profile is null)
            {
                throw new System.ArgumentNullException(nameof(profile));
            }

            if (targetProject is null)
            {
                throw new System.ArgumentNullException(nameof(targetProject));
            }

            var rootedPath = _owningProject.MakeRelative(targetProject.FullPath);

            profile.OtherSettings[Constants.TargetProjectKeyName] = rootedPath;
        }
Ejemplo n.º 14
0
        private void UpdateLaunchTypes()
        {
            // Populate the set of unique launch types from the list of providers since there can be duplicates with different priorities. However,
            // the command name will be the same so we can grab the first one for the purposes of populating the list
            if (_providerLaunchTypes == null)
            {
                _providerLaunchTypes = new List <LaunchType>();
                foreach (Lazy <ILaunchSettingsUIProvider, IOrderPrecedenceMetadataView> provider in _uiProviders)
                {
                    if (_providerLaunchTypes.FirstOrDefault((lt) => lt.CommandName.Equals(provider.Value.CommandName)) == null)
                    {
                        _providerLaunchTypes.Add(new LaunchType()
                        {
                            CommandName = provider.Value.CommandName, Name = provider.Value.FriendlyName
                        });
                    }
                }
            }

            IWritableLaunchProfile selectedProfile    = SelectedDebugProfile;
            LaunchType             selectedLaunchType = null;

            _launchTypes = new List <LaunchType>();
            if (selectedProfile != null)
            {
                _launchTypes.AddRange(_providerLaunchTypes);

                selectedLaunchType = _launchTypes.FirstOrDefault((launchType) => string.Equals(launchType.CommandName, selectedProfile.CommandName));
                if (selectedLaunchType == null)
                {
                    selectedLaunchType = new LaunchType()
                    {
                        CommandName = selectedProfile.CommandName, Name = selectedProfile.CommandName
                    };
                    _launchTypes.Insert(0, selectedLaunchType);
                }
            }

            // Need to notify the list has changed prior to changing the selected one
            OnPropertyChanged(nameof(LaunchTypes));

            SelectedLaunchType = selectedLaunchType;
        }
Ejemplo n.º 15
0
 protected override void UpdateActiveLaunchProfile(IWritableLaunchProfile activeLaunchProfile, string newValue)
 {
     activeLaunchProfile.WorkingDirectory = newValue;
 }
Ejemplo n.º 16
0
 protected override void UpdateActiveLaunchProfile(IWritableLaunchProfile activeLaunchProfile, string newValue)
 {
     activeLaunchProfile.ExecutablePath = newValue;
 }
 protected override void UpdateActiveLaunchProfile(IWritableLaunchProfile activeLaunchProfile, string newValue)
 {
     activeLaunchProfile.CommandName = newValue;
 }
 /// <summary>
 /// Updates the <paramref name="activeLaunchProfile"/> with a new value.
 /// </summary>
 /// <param name="activeLaunchProfile">The <see cref="ILaunchProfile"/> to update.</param>
 /// <param name="newValue">The new value property value.</param>
 protected abstract void UpdateActiveLaunchProfile(IWritableLaunchProfile activeLaunchProfile, string newValue);