protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            // Saving state to global settings
            mySettingsStore.SetValue((FindTextSettings s) => s.LastUsedText, SearchString);
            mySettingsStore.SetValue((FindTextSettings s) => s.LastUsedFlags, SearchFlags);
        }
        protected override void MutateSettings(IContextBoundSettingsStore settingsStore)
        {
            settingsStore.SetValue((XmlDocInspectionsSettings s) => s.TypeAccessibility, AccessibilitySettingFlags.None);
            settingsStore.SetValue((XmlDocInspectionsSettings s) => s.TypeMemberAccessibility, AccessibilitySettingFlags.None);

            var attribute = settingsStore.GetValue((XmlDocInspectionsSettings s) => s.IncludeAttributeFullNames);

            Assert.IsTrue(attribute == "JetBrains.Annotations.PublicAPIAttribute"); // Fixate default value

            // Prove that the setting can contain spaces and duplicates:
            settingsStore.SetValue((XmlDocInspectionsSettings s) => s.IncludeAttributeFullNames, $"{attribute}  , {attribute}  ");
        }
        protected static void ClearRegExSettingsPriorToRun(IContextBoundSettingsStore settingsStore)
        {
            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.TestProjectToCodeProjectNameSpaceRegEx, "NOT SET BY TEST");
            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.TestProjectToCodeProjectNameSpaceRegExReplace, "NOT SET BY TEST");
            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.TestProjectNameToCodeProjectNameRegEx, "NOT SET BY TEST");

            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.SingleTestRegexTestToAssembly, "NOT SET BY TEST");
        }
예제 #4
0
        internal static void SetupTestCopSettings(IContextBoundSettingsStore settingsStore)
        {
            const string altRegEx = "^(.*?)\\.?(Integration)*Tests$";

            ClearRegExSettingsPriorToRun(settingsStore);

            settingsStore.SetValue <TestFileAnalysisSettings, bool>(
                s => s.FindOrphanedProjectFiles, true);

            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.TestClassSuffix, "Tests,IntegrationTests");

            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.TestProjectToCodeProjectNameSpaceRegEx, altRegEx);
            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.TestProjectToCodeProjectNameSpaceRegExReplace, "$1");
        }
예제 #5
0
 private static void MigrateValue(
     [NotNull] IContextBoundSettingsStore store,
     [NotNull] Expression <Func <IdentifierTooltipSettings, AnnotationsDisplayKind> > oldSettingExpr,
     [NotNull] Expression <Func <IdentifierTooltipSettings, AttributesDisplayKind> > newSettingExpr)
 {
     if (!store.IsEntryEqualToDefault(oldSettingExpr) && store.IsEntryEqualToDefault(newSettingExpr))
     {
         AnnotationsDisplayKind annotationsDisplayKind = store.GetValue(oldSettingExpr);
         store.SetValue(newSettingExpr, annotationsDisplayKind.ToAttributesDisplayKind());
     }
 }
 private static void MigrateValue <TDisplayKind>(
     IContextBoundSettingsStore store,
     Expression <Func <IdentifierTooltipSettings, bool> > oldSettingExpr,
     Expression <Func <IdentifierTooltipSettings, TDisplayKind> > newSettingExpr,
     TDisplayKind trueValue,
     TDisplayKind falseValue)
     where TDisplayKind : struct
 {
     if (!store.IsEntryEqualToDefault(oldSettingExpr) && store.IsEntryEqualToDefault(newSettingExpr))
     {
         TDisplayKind displayKind = store.GetValue(oldSettingExpr) ? trueValue : falseValue;
         store.SetValue(newSettingExpr, displayKind);
     }
 }
예제 #7
0
        protected override void DoTest(IProject testProject)
        {
            IPsiServices psiServices = testProject.GetSolution().GetPsiServices();
            IContextBoundSettingsStore boundStore = psiServices.SettingsStore.BindToContextTransient(
                ContextRange.Smart(testProject.ToDataContext()));

            boundStore.SetValue <OrderUsingsSettings, string>(
                settings => settings.OrderSpecificationXml,
                "<Groups xmlns=\"http://schemas.interact-sw.co.uk/OrderUsings/2014\">" +
                "<Group Priority='1' NamespacePattern='System*' />" +
                "<Group Priority='1' NamespacePattern='Microsoft*' />" +
                "<Space />" +
                "<Group Priority='9999' NamespacePattern='*' />" +
                "<Space />" +
                "<Group Priority='9999' NamespacePattern='*' AliasPattern='*' Type='Alias' />" +
                "</Groups>");

            base.DoTest(testProject);
        }
예제 #8
0
        // This seems to be the earliest place from which we can get a settings store. We use
        // this to push in settings without having to use a real settings file. (It looks like
        // you can actually provide a test-local settings file, but for now, just providing it
        // programmatically is easiest.)
        protected override void WithProject(IProject project, ISettingsStore settingsStore, Action action)
        {
            // The docs all say to use plain BindToContext, but that has been marked as [Obsolete].
            // This appears to be what that obsolete method actually does. (And teh DataContexts.Empty
            // just copies what the test code uses when it creates a bound settings store to pass to the
            // code under test.)
            IContextBoundSettingsStore boundStore = settingsStore.BindToContextTransient(
                ContextRange.ManuallyRestrictWritesToOneContext(
                    (lifetime, contexts) => settingsStore.DataContexts.Empty));

            boundStore.SetValue <OrderUsingsSettings, string>(
                settings => settings.OrderSpecificationXml,
                "<Groups xmlns=\"http://schemas.interact-sw.co.uk/OrderUsings/2014\">" +
                "<Group Priority='1' NamespacePattern='System*' />" +
                "<Group Priority='1' NamespacePattern='Microsoft*' />" +
                "<Space />" +
                "<Group Priority='9999' NamespacePattern='*' />" +
                "<Space />" +
                "<Group Priority='9999' NamespacePattern='*' AliasPattern='*' Type='Alias' />" +
                "</Groups>");
            base.WithProject(project, settingsStore, action);
        }
        internal static void SetupTestCopSettings(IContextBoundSettingsStore settingsStore)
        {
            ClearRegExSettingsPriorToRun(settingsStore);

            settingsStore.SetValue <TestFileAnalysisSettings, TestProjectStrategy>(
                s => s.TestCopProjectStrategy, TestProjectStrategy.SingleTestProjectPerSolution);

            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.SingleTestRegexTestToAssembly, RegExTests.RegexForSingleTestProjectStrategy);
            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.SingleTestRegexTestToAssemblyProjectReplace, @"$1$2");
            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.SingleTestRegexTestToAssemblyProjectSubNamespaceReplace, @"$3");
            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.SingleTestRegexCodeToTestAssembly, @"^(.*?\..*?)(\..*?)$");
            settingsStore.SetValue <TestFileAnalysisSettings, string>(
                s => s.SingleTestRegexCodeToTestReplace, @"$2");
        }
예제 #10
0
 protected override void MutateSettings(IContextBoundSettingsStore settingsStore)
 {
     base.MutateSettings(settingsStore);
     settingsStore.SetValue((XmlDocInspectionsSettings s) => s.ExcludeMembersOverridingSuperMember, true);
 }
 protected override void MutateSettings(IContextBoundSettingsStore settingsStore)
 {
     settingsStore.SetValue((XmlDocInspectionsSettings s) => s.ProjectExclusionRegex, ProjectExclusionRegexValue);
 }
예제 #12
0
 protected override void ChangeSettings(IContextBoundSettingsStore store)
 {
     base.ChangeSettings(store);
     store.SetValue((ImplicitNullabilitySettings s) => s.EnableTypeHighlighting, false);
 }
예제 #13
0
 protected static void EnableAllXmlDocOptions(IContextBoundSettingsStore settingsStore)
 {
     settingsStore.SetValue((XmlDocInspectionsSettings s) => s.TypeAccessibility, AccessibilitySettingFlags.All);
     settingsStore.SetValue((XmlDocInspectionsSettings s) => s.TypeMemberAccessibility, AccessibilitySettingFlags.All);
 }
예제 #14
0
 protected override void MutateSettings(IContextBoundSettingsStore settingsStore)
 {
     EnableAllXmlDocOptions(settingsStore);
     settingsStore.SetValue((XmlDocInspectionsSettings s) => s.ExcludeConstructors, true);
 }
        public static void EnableImplicitNullability(
            this IContextBoundSettingsStore settingsStore,
            bool enableInputParameters        = false,
            bool enableRefParameters          = false,
            bool enableOutParametersAndResult = false,
            bool enableFields                       = false,
            bool fieldsRestrictToReadonly           = false,
            bool fieldsRestrictToReferenceTypes     = false,
            bool enableProperties                   = false,
            bool propertiesRestrictToGetterOnly     = false,
            bool propertiesRestrictToReferenceTypes = false,
            GeneratedCodeOptions generatedCode      = GeneratedCodeOptions.Exclude)
        {
            // Fixate default values:
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.Enabled), Is.False);
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.EnableInputParameters), Is.True);
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.EnableRefParameters), Is.True);
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.EnableOutParametersAndResult), Is.True);
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.EnableFields), Is.True);
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.FieldsRestrictToReadonly), Is.True);
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.FieldsRestrictToReferenceTypes), Is.False);
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.EnableProperties), Is.True);
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.PropertiesRestrictToGetterOnly), Is.True);
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.PropertiesRestrictToReferenceTypes), Is.False);
            Assert.That(settingsStore.GetValue((ImplicitNullabilitySettings s) => s.GeneratedCode), Is.EqualTo(GeneratedCodeOptions.Exclude));

            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.Enabled, true);
            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.EnableInputParameters, enableInputParameters);
            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.EnableRefParameters, enableRefParameters);
            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.EnableOutParametersAndResult, enableOutParametersAndResult);
            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.EnableFields, enableFields);
            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.FieldsRestrictToReadonly, fieldsRestrictToReadonly);
            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.FieldsRestrictToReferenceTypes, fieldsRestrictToReferenceTypes);
            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.EnableProperties, enableProperties);
            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.PropertiesRestrictToGetterOnly, propertiesRestrictToGetterOnly);
            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.PropertiesRestrictToReferenceTypes, propertiesRestrictToReferenceTypes);
            settingsStore.SetValue((ImplicitNullabilitySettings s) => s.GeneratedCode, generatedCode);
        }