コード例 #1
0
 private void SetSymbolSpecificationListFromXElement(XElement symbolSpecificationsElement)
 {
     foreach (var symbolSpecificationElement in symbolSpecificationsElement.Elements(nameof(SymbolSpecification)))
     {
         SymbolSpecifications.Add(SymbolSpecification.FromXElement(symbolSpecificationElement));
     }
 }
コード例 #2
0
        private string MethodNamesArePascalCaseOptionString()
        {
            var symbolSpecification = new SymbolSpecification(
                Guid.NewGuid(),
                "Name",
                SpecializedCollections.SingletonEnumerable(new SymbolSpecification.SymbolKindOrTypeKind(SymbolKind.Method)).ToList(),
                SpecializedCollections.EmptyList<SymbolSpecification.AccessibilityKind>(),
                SpecializedCollections.EmptyList<SymbolSpecification.ModifierKind>());

            var namingStyle = new NamingStyle();
            namingStyle.CapitalizationScheme = Capitalization.PascalCase;
            namingStyle.Name = "Name";
            namingStyle.Prefix = "";
            namingStyle.Suffix = "";
            namingStyle.WordSeparator = "";


            var namingRule = new SerializableNamingRule();
            namingRule.SymbolSpecificationID = symbolSpecification.ID;
            namingRule.NamingStyleID = namingStyle.ID;
            namingRule.EnforcementLevel = DiagnosticSeverity.Error;

            var info = new SerializableNamingStylePreferencesInfo();
            info.SymbolSpecifications.Add(symbolSpecification);
            info.NamingStyles.Add(namingStyle);
            info.NamingRules.Add(namingRule);

            return info.CreateXElement().ToString();
        }
コード例 #3
0
 public static NamingStylePreferences ReadFrom(ObjectReader reader)
 {
     return(new NamingStylePreferences(
                reader.ReadArray(r => SymbolSpecification.ReadFrom(r)),
                reader.ReadArray(r => NamingStyle.ReadFrom(r)),
                reader.ReadArray(r => SerializableNamingRule.ReadFrom(r))));
 }
コード例 #4
0
 public NamingRule(string title, ImmutableArray <NamingRule> children, SymbolSpecification symbolSpecification, NamingStyle namingStyle, DiagnosticSeverity enforcementLevel)
 {
     Title               = title;
     Children            = children;
     SymbolSpecification = symbolSpecification;
     NamingStyle         = namingStyle;
     EnforcementLevel    = enforcementLevel;
 }
コード例 #5
0
ファイル: NamingRule.cs プロジェクト: Rickinio/roslyn
 public NamingRule(string title, ImmutableArray<NamingRule> children, SymbolSpecification symbolSpecification, NamingStyle namingStyle, DiagnosticSeverity enforcementLevel)
 {
     Title = title;
     Children = children;
     SymbolSpecification = symbolSpecification;
     NamingStyle = namingStyle;
     EnforcementLevel = enforcementLevel;
 }
コード例 #6
0
 public NamingRule(
     SymbolSpecification symbolSpecification,
     NamingStyle namingStyle,
     ReportDiagnostic enforcementLevel
     )
 {
     SymbolSpecification = symbolSpecification;
     NamingStyle         = namingStyle;
     EnforcementLevel    = enforcementLevel;
 }
コード例 #7
0
        internal static SymbolSpecification FromXElement(XElement symbolSpecificationElement)
        {
            var result = new SymbolSpecification();

            result.ID   = Guid.Parse(symbolSpecificationElement.Attribute(nameof(ID)).Value);
            result.Name = symbolSpecificationElement.Attribute(nameof(Name)).Value;

            result.PopulateSymbolKindListFromXElement(symbolSpecificationElement.Element(nameof(ApplicableSymbolKindList)));
            result.PopulateAccessibilityListFromXElement(symbolSpecificationElement.Element(nameof(ApplicableAccessibilityList)));
            result.PopulateModifierListFromXElement(symbolSpecificationElement.Element(nameof(RequiredModifierList)));

            return(result);
        }
        private static bool TryGetSerializableNamingRule(
            string namingRuleTitle,
            SymbolSpecification symbolSpec,
            NamingStyle namingStyle,
            IReadOnlyDictionary <string, string> conventionsDictionary,
            out SerializableNamingRule serializableNamingRule)
        {
            if (!TryGetRuleSeverity(namingRuleTitle, conventionsDictionary, out var severity))
            {
                serializableNamingRule = null;
                return(false);
            }

            serializableNamingRule = new SerializableNamingRule()
            {
                EnforcementLevel      = severity,
                NamingStyleID         = namingStyle.ID,
                SymbolSpecificationID = symbolSpec.ID
            };

            return(true);
        }
コード例 #9
0
        private static bool TryGetSymbolSpec(
            string namingRuleTitle,
            IReadOnlyDictionary <string, object> conventionsDictionary,
            out SymbolSpecification symbolSpec)
        {
            symbolSpec = null;
            if (!TryGetSymbolSpecNameForNamingRule(namingRuleTitle, conventionsDictionary, out string symbolSpecName))
            {
                return(false);
            }

            var applicableKinds           = GetSymbolsApplicableKinds(symbolSpecName, conventionsDictionary);
            var applicableAccessibilities = GetSymbolsApplicableAccessibilities(symbolSpecName, conventionsDictionary);
            var requiredModifiers         = GetSymbolsRequiredModifiers(symbolSpecName, conventionsDictionary);

            symbolSpec = new SymbolSpecification(
                symbolSpecName,
                symbolKindList: applicableKinds,
                accessibilityList: applicableAccessibilities,
                modifiers: requiredModifiers);
            return(true);
        }
コード例 #10
0
        public SymbolSpecificationViewModel(string languageName, SymbolSpecification specification, bool canBeDeleted, INotificationService notificationService)
        {
            CanBeDeleted = canBeDeleted;
            _notificationService = notificationService;
            ItemName = specification.Name;
            ID = specification.ID;

            // The list of supported SymbolKinds is limited due to https://github.com/dotnet/roslyn/issues/8753.
            if (languageName == LanguageNames.CSharp)
            {
                SymbolKindList = new List<SymbolKindViewModel>
                {
                    new SymbolKindViewModel(TypeKind.Class, "class", specification),
                    new SymbolKindViewModel(TypeKind.Struct, "struct", specification),
                    new SymbolKindViewModel(TypeKind.Interface, "interface", specification),
                    new SymbolKindViewModel(TypeKind.Enum, "enum", specification),
                    new SymbolKindViewModel(SymbolKind.Property, "property", specification),
                    new SymbolKindViewModel(SymbolKind.Method, "method", specification),
                    new SymbolKindViewModel(SymbolKind.Field, "field", specification),
                    new SymbolKindViewModel(SymbolKind.Event, "event", specification),
                    new SymbolKindViewModel(TypeKind.Delegate, "delegate", specification),
                };

                AccessibilityList = new List<AccessibilityViewModel>
                {
                    new AccessibilityViewModel(Accessibility.Public, "public", specification),
                    new AccessibilityViewModel(Accessibility.Internal, "internal", specification),
                    new AccessibilityViewModel(Accessibility.Private, "private", specification),
                    new AccessibilityViewModel(Accessibility.Protected, "protected", specification),
                    new AccessibilityViewModel(Accessibility.ProtectedOrInternal, "protected internal", specification),
                };

                ModifierList = new List<ModifierViewModel>
                {
                    new ModifierViewModel(DeclarationModifiers.Abstract, "abstract", specification),
                    new ModifierViewModel(DeclarationModifiers.Async, "async", specification),
                    new ModifierViewModel(DeclarationModifiers.Const, "const", specification),
                    new ModifierViewModel(DeclarationModifiers.ReadOnly, "readonly", specification),
                    new ModifierViewModel(DeclarationModifiers.Static, "static", specification)
                };
            }
            else if (languageName == LanguageNames.VisualBasic)
            {
                SymbolKindList = new List<SymbolKindViewModel>
                {
                    new SymbolKindViewModel(TypeKind.Class, "Class", specification),
                    new SymbolKindViewModel(TypeKind.Struct, "Structure", specification),
                    new SymbolKindViewModel(TypeKind.Interface, "Interface", specification),
                    new SymbolKindViewModel(TypeKind.Enum, "Enum", specification),
                    new SymbolKindViewModel(TypeKind.Module, "Module", specification),
                    new SymbolKindViewModel(SymbolKind.Property, "Property", specification),
                    new SymbolKindViewModel(SymbolKind.Method, "Method", specification),
                    new SymbolKindViewModel(SymbolKind.Field, "Field", specification),
                    new SymbolKindViewModel(SymbolKind.Event, "Event", specification),
                    new SymbolKindViewModel(TypeKind.Delegate, "Delegate", specification),
                };

                AccessibilityList = new List<AccessibilityViewModel>
                {
                    new AccessibilityViewModel(Accessibility.Public, "Public", specification),
                    new AccessibilityViewModel(Accessibility.Friend, "Friend", specification),
                    new AccessibilityViewModel(Accessibility.Private, "Private", specification),
                    new AccessibilityViewModel(Accessibility.Protected , "Protected", specification),
                    new AccessibilityViewModel(Accessibility.ProtectedOrInternal, "Protected Friend", specification),
                };

                ModifierList = new List<ModifierViewModel>
                {
                    new ModifierViewModel(DeclarationModifiers.Abstract, "MustInherit", specification),
                    new ModifierViewModel(DeclarationModifiers.Async, "Async", specification),
                    new ModifierViewModel(DeclarationModifiers.Const, "Const", specification),
                    new ModifierViewModel(DeclarationModifiers.ReadOnly, "ReadOnly", specification),
                    new ModifierViewModel(DeclarationModifiers.Static, "Shared", specification)
                };
            }
            else
            {
                throw new ArgumentException(string.Format("Unexpected language name: {0}", languageName), nameof(languageName));
            }
        }
コード例 #11
0
            public ModifierViewModel(DeclarationModifiers modifier, string name, SymbolSpecification specification)
            {
                _modifier = modifier;
                Name = name;

                IsChecked = specification.RequiredModifierList.Any(m => m.Modifier == modifier);
            }
コード例 #12
0
            public AccessibilityViewModel(Accessibility accessibility, string name, SymbolSpecification specification)
            {
                _accessibility = accessibility;
                Name = name;

                IsChecked = specification.ApplicableAccessibilityList.Any(a => a.Accessibility == accessibility);
            }
コード例 #13
0
 public SymbolKindViewModel(TypeKind typeKind, string name, SymbolSpecification specification)
 {
     this._typeKind = typeKind;
     Name = name;
     IsChecked = specification.ApplicableSymbolKindList.Any(k => k.TypeKind == typeKind);
 }
コード例 #14
0
ファイル: SymbolSpecification.cs プロジェクト: jkotas/roslyn
        internal static SymbolSpecification FromXElement(XElement symbolSpecificationElement)
        {
            var result = new SymbolSpecification();
            result.ID = Guid.Parse(symbolSpecificationElement.Attribute(nameof(ID)).Value);
            result.Name = symbolSpecificationElement.Attribute(nameof(Name)).Value;

            result.PopulateSymbolKindListFromXElement(symbolSpecificationElement.Element(nameof(ApplicableSymbolKindList)));
            result.PopulateAccessibilityListFromXElement(symbolSpecificationElement.Element(nameof(ApplicableAccessibilityList)));
            result.PopulateModifierListFromXElement(symbolSpecificationElement.Element(nameof(RequiredModifierList)));

            return result;
        }
コード例 #15
0
ファイル: NamingRule.cs プロジェクト: XieShuquan/roslyn
 public NamingRule(SymbolSpecification symbolSpecification, NamingStyle namingStyle, DiagnosticSeverity enforcementLevel)
 {
     SymbolSpecification = symbolSpecification;
     NamingStyle = namingStyle;
     EnforcementLevel = enforcementLevel;
 }
コード例 #16
0
 public CustomTagViewModel(string name, SymbolSpecification specification)
 {
     Name = name;
     IsChecked = specification.RequiredCustomTagList.Contains(name);
 }