/// <summary> /// Gets the configuration type. /// </summary> private ProjectInfo.ProjectTypeEnum parseConfiguration_Type(VCConfiguration vcConfiguration) { ProjectInfo.ProjectTypeEnum result = ProjectInfo.ProjectTypeEnum.INVALID; // We get the Visual Studio confiuration type... ConfigurationTypes configurationType = Utils.call(() => (vcConfiguration.ConfigurationType)); // And convert it to our enum type... switch (configurationType) { case ConfigurationTypes.typeApplication: result = ProjectInfo.ProjectTypeEnum.CPP_EXECUTABLE; break; case ConfigurationTypes.typeStaticLibrary: result = ProjectInfo.ProjectTypeEnum.CPP_STATIC_LIBRARY; break; case ConfigurationTypes.typeDynamicLibrary: result = ProjectInfo.ProjectTypeEnum.CPP_DLL; break; } return(result); }
public override IEnumerable <Diagnostic> Analyze(Compilation compilation, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancel) { var interfaceSyntax = (InterfaceDeclarationSyntax)node; var types = new ConfigurationTypes(compilation); var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceSyntax, cancel); if (interfaceSymbol == null) { yield break; } if (!interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationCollectionAttribute))) { yield break; } foreach (var childIface in interfaceSymbol.AllInterfaces.Reverse().Concat(new [] { interfaceSymbol })) { if (SymbolEqualityComparer.Default.Equals(childIface, types.IConfigurationCollectionTemplate)) { continue; } foreach (var member in childIface.GetMembers().Where(s => s.Kind == SymbolKind.Property).Cast <IPropertySymbol>()) { if (member.Type.TypeKind != TypeKind.Interface || !member.Type.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationSectionAttribute))) { yield return(Diagnostic.Create(Rule, member.Locations.FirstOrDefault(), member.Name)); } } } }
public void Init_GetVarableReport(string name, string val, ConfigurationTypes type, bool isArray) { var root = new ConfigurationRoot(new IConfigurationProvider[0]); var infos = new IConfigurationChangeInfo[] { new ConfigurationChangeInfo { Key = name, Old = "1", New = val, Sender = root, Provider = null, IsCreate = false } }; var rep = ChangeReport.FromChanges(root, infos); var c = rep.First().GetValueReport(); Assert.AreEqual(name, c.Keys.Single()); var r = c.Values.Single(); Assert.AreEqual(isArray, r.IsArray); Assert.AreEqual(type, r.TypeCode); Assert.AreEqual(root, r.Configuration); Assert.AreEqual(infos[0], r.Info); }
public override IEnumerable <Diagnostic> Analyze(Compilation compilation, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancel) { var types = new ConfigurationTypes(compilation); var interfaceSymbol = semanticModel.GetDeclaredSymbol(node, cancel) as INamedTypeSymbol; if (interfaceSymbol == null) { yield break; } if (!interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationCollectionAttribute) || SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.InputConfigurationAttribute) || SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationSectionAttribute))) { yield break; } foreach (var member in interfaceSymbol.GetMembers()) { // Ignore accessor implementations for this diagnostic. if (member is IMethodSymbol accessor && accessor.AssociatedSymbol is IPropertySymbol) { continue; } if (member is not IPropertySymbol propertySymbol || propertySymbol.IsIndexer) { yield return(Diagnostic.Create(Rule, member.Locations.FirstOrDefault(), member.Kind, interfaceSymbol.Name, member.Name)); } } }
public void Execute(GeneratorExecutionContext context) { if (context.SyntaxReceiver is not ConfigurationTemplateInterfaceSyntaxReceiver receiver) { return; } var compilation = context.Compilation; var types = new ConfigurationTypes(compilation); if (!types.CheckContext(context)) { return; } foreach (var ifaceSyntax in receiver.CandidateInterfaces) { var model = compilation.GetSemanticModel(ifaceSyntax.SyntaxTree); var ifaceSymbol = model.GetDeclaredSymbol(ifaceSyntax, context.CancellationToken); if (ifaceSymbol == null) { continue; } if (!ifaceSymbol.GetAttributes() .Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationCollectionAttribute))) { continue; } var diagnostics = Analyzers.AsParallel() .SelectMany(a => a.Analyze(context.Compilation, model, ifaceSyntax, context.CancellationToken)) .ToList(); foreach (var diag in diagnostics) { context.ReportDiagnostic(diag); } if (diagnostics.Any()) { return; } var properties = new List <(INamedTypeSymbol, IPropertySymbol)>(); // Add collection props bottom up. foreach (var childIface in ifaceSymbol.AllInterfaces.Reverse().Concat(new[] { ifaceSymbol })) { foreach (var member in childIface.GetMembers()) { if (member is IPropertySymbol property) { properties.Add((childIface, property !)); } } } string classSource = GenerateSource(ifaceSymbol, properties, types); context.AddSource($"{ifaceSymbol.Name}_ConfigurationCollection.g.cs", SourceText.From(classSource, Encoding.UTF8)); } }
public override IEnumerable <Diagnostic> Analyze(Compilation compilation, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancel) { var interfaceSyntax = (InterfaceDeclarationSyntax)node; var types = new ConfigurationTypes(compilation); var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceSyntax, cancel); if (interfaceSymbol == null) { yield break; } if (!interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationCollectionAttribute) || SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationSectionAttribute) || SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.InputConfigurationAttribute))) { yield break; } foreach (var childIface in interfaceSymbol.AllInterfaces.Reverse().Concat(new[] { interfaceSymbol })) { if (SymbolEqualityComparer.Default.Equals(childIface, types.IConfigurationCollectionTemplate) || SymbolEqualityComparer.Default.Equals(childIface, types.IInputConfigurationTemplate)) { continue; } foreach (var member in childIface.GetMembers().Where(s => s.Kind == SymbolKind.Property).Cast <IPropertySymbol>()) { if (member.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() is not PropertyDeclarationSyntax propertySyntax) { continue; } if (propertySyntax.ExpressionBody is ArrowExpressionClauseSyntax expressionGet) { yield return(Diagnostic.Create(Rule, expressionGet.GetLocation(), member.Name, "get")); continue; } if (propertySyntax.AccessorList is AccessorListSyntax accessors) { foreach (var accessor in accessors.Accessors) { if (accessor.ExpressionBody != null || accessor.Body != null) { yield return(Diagnostic.Create(Rule, accessor.GetLocation(), member.Name, accessor.Keyword.Text)); } } } } } }
public ChangeValueInfo( IConfiguration configuration, IConfigurationChangeInfo info, ConfigurationTypes typeCode, bool isArray) { Configuration = configuration; Info = info; TypeCode = typeCode; IsArray = isArray; }
public override IEnumerable <Diagnostic> Analyze(Compilation compilation, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancel) { var interfaceSyntax = (InterfaceDeclarationSyntax)node; var types = new ConfigurationTypes(compilation); var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceSyntax, cancel); if (interfaceSymbol == null) { yield break; } if (!interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationSectionAttribute) || SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.InputConfigurationAttribute))) { yield break; } foreach (var childIface in interfaceSymbol.AllInterfaces.Reverse().Concat(new[] { interfaceSymbol })) { foreach (var member in childIface.GetMembers().Where(s => s.Kind == SymbolKind.Property).Cast <IPropertySymbol>()) { if (member.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() is not PropertyDeclarationSyntax propertySyntax) { continue; } if (!member.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationOptionAttribute) || SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.InputOptionAttribute))) { continue; } if (propertySyntax.AccessorList is not AccessorListSyntax accessors || accessors.Accessors.FirstOrDefault(a => a.IsKind(SyntaxKind.GetAccessorDeclaration)) is not AccessorDeclarationSyntax getAccessor || getAccessor.Modifiers.Any()) { if (interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationSectionAttribute))) { yield return(Diagnostic.Create(SectionRule, propertySyntax.GetLocation(), member.Name)); } if (interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.InputConfigurationAttribute))) { yield return(Diagnostic.Create(InputRule, propertySyntax.GetLocation(), member.Name)); } } } } }
public override IEnumerable <Diagnostic> Analyze(Compilation compilation, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancel) { var interfaceSyntax = (InterfaceDeclarationSyntax)node; var types = new ConfigurationTypes(compilation); var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceSyntax, cancel); if (interfaceSymbol == null) { yield break; } if (!interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationCollectionAttribute))) { yield break; } var targetAttrs = new List <AttributeData>(); foreach (var childIface in interfaceSymbol.AllInterfaces.Reverse().Concat(new[] { interfaceSymbol })) { targetAttrs.AddRange(childIface.GetAttributes() .Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationTargetAttribute))); } var declaredTargets = new HashSet <string>(); // null target always exists. declaredTargets.Add("#null"); foreach (var targetAttr in targetAttrs) { if (targetAttr.ConstructorArguments.Length > 0) { string rootTarget = (string)targetAttr.ConstructorArguments[0].Value !; if (!declaredTargets.Contains(rootTarget)) { declaredTargets.Add(rootTarget); } else { yield return(Diagnostic.Create(Rule, targetAttr.ApplicationSyntaxReference?.GetSyntax().GetLocation(), rootTarget, interfaceSymbol.Name )); } } } }
public bool isMakefileConfiguration() { ConfigurationTypes configurationType = _wrapped.ConfigurationType; if (configurationType == ConfigurationTypes.typeGeneric) { return(true); } if (configurationType == ConfigurationTypes.typeUnknown && GetNMakeTool() != null && GetNMakeTool().isValid()) { return(true); } return(false); }
public override IEnumerable <Diagnostic> Analyze(Compilation compilation, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancel) { var interfaceSyntax = (InterfaceDeclarationSyntax)node; var types = new ConfigurationTypes(compilation); var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceSyntax, cancel); if (interfaceSymbol == null) { yield break; } if (!interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationSectionAttribute) || SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.InputConfigurationAttribute))) { yield break; } foreach (var childIface in interfaceSymbol.AllInterfaces.Reverse().Concat(new[] { interfaceSymbol })) { foreach (var member in childIface.GetMembers().Where(s => s.Kind == SymbolKind.Property).Cast <IPropertySymbol>()) { if (member.GetAttributes() .FirstOrDefault(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationOptionAttribute)) is not AttributeData attribute) { continue; } // If attribute has a second arg, then it must not be GUID-based if (attribute.ConstructorArguments.Skip(1).FirstOrDefault().Type is ITypeSymbol defaultType) { if (!SymbolEqualityComparer.Default.Equals(defaultType, member.Type)) { yield return(Diagnostic.Create(Rule, member.Locations.FirstOrDefault(), member.Name, member.Type, defaultType)); } } else if (attribute.ConstructorArguments.Length == 1 && !SymbolEqualityComparer.Default.Equals(member.Type, types.System_Guid)) { yield return(Diagnostic.Create(Rule, member.Locations.FirstOrDefault(), member.Name, member.Type, types.System_Guid)); } } } }
/// <summary> /// Obtiene el valor colocado bajo la llave proporcionada en el archivo de Configuracion del proyecto. /// </summary> /// <param name="key">Llave a localizar.</param> /// <param name="type">Especifica el tipo de configuracion al que pertenece la llave.</param> /// <returns>Regresa el valor obtenido del archivo de configuracion, si la llave fue encontrada.</returns> public static string GetValueFromConfiguration(string key, ConfigurationTypes type) { #if NET461 switch (type) { case ConfigurationTypes.ConnectionString: if (ConfigurationManager.ConnectionStrings[key] == null) { throw new ConfigurationNotFoundException(key); } return(ConfigurationManager.ConnectionStrings[key].ConnectionString); case ConfigurationTypes.AppSetting: if (ConfigurationManager.AppSettings[key] == null) { throw new ConfigurationNotFoundException(key); } return(ConfigurationManager.AppSettings[key]); default: throw new ConfigurationNotFoundException(key); } #endif #if NETSTANDARD2_0 switch (type) { case ConfigurationTypes.ConnectionString: if (_configuration.GetSection("ConnectionStrings")[key] == null) { throw new ConfigurationNotFoundException(key); } return(_configuration.GetSection("ConnectionStrings")[key]); case ConfigurationTypes.AppSetting: if (_configuration.GetSection("AppSettings")[key] == null) { throw new ConfigurationNotFoundException(key); } return(_configuration.GetSection("AppSettings")[key]); default: throw new ConfigurationNotFoundException(key); } #endif }
public override IEnumerable <Diagnostic> Analyze(Compilation compilation, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancel) { var interfaceSyntax = (InterfaceDeclarationSyntax)node; var types = new ConfigurationTypes(compilation); var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceSyntax, cancel); if (interfaceSymbol == null) { yield break; } if (!interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationSectionAttribute) || SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.InputConfigurationAttribute))) { yield break; } foreach (var childIface in interfaceSymbol.AllInterfaces.Reverse().Concat(new[] { interfaceSymbol })) { foreach (var member in childIface.GetMembers().Where(s => s.Kind == SymbolKind.Property).Cast <IPropertySymbol>()) { if (member.GetAttributes() .FirstOrDefault(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationOptionAttribute)) is not AttributeData) { continue; } if (member.Type.TypeKind != TypeKind.Enum) { continue; } if (!member.Type.GetMembers().Where(e => e.Kind == SymbolKind.Field) .All(e => e.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.SelectionOptionAttribute)))) { var propertySyntax = member.DeclaringSyntaxReferences.First(); if (propertySyntax.GetSyntax().GetDiagnostics().Any(d => d.Id == DiagnosticCodes.SFC012__SectionPropertyEnumUndecorated)) { continue; } yield return(Diagnostic.Create(Rule, member.Locations.FirstOrDefault(), member.Name, member.Type)); } } } }
public override IEnumerable <Diagnostic> Analyze(Compilation compilation, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancel) { var interfaceSyntax = (InterfaceDeclarationSyntax)node; var types = new ConfigurationTypes(compilation); var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceSyntax, cancel); if (interfaceSymbol == null) { yield break; } if (interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.InputConfigurationAttribute)) && interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationSectionAttribute))) { yield return(Diagnostic.Create(Rule, interfaceSymbol.Locations.First(), interfaceSymbol.Name)); } }
public bool isMakefileConfiguration() { try { ConfigurationTypes configurationType = _wrapped.ConfigurationType; if (configurationType == ConfigurationTypes.typeGeneric) { return(true); } if (configurationType == ConfigurationTypes.typeUnknown && GetNMakeTool() != null && GetNMakeTool().isValid()) { return(true); } } catch { Logging.LogWarning("Unable to determine if a makefile configuration is used, falling back to default behavior."); } return(false); }
/****************************************************************/ #endregion /* LifeCycle */ #region Private Operations /****************************************************************/ /// <summary> /// Set true to flag that responses target type /// </summary> /// <param name="configType"></param> private void iSetTargetFlags(ConfigurationTypes configType) { switch (configType)//dynamiclib or staticlib and etc. { case (ConfigurationTypes.typeApplication): exeflag = true; dllflag = false; libflag = false; break; case (ConfigurationTypes.typeDynamicLibrary): exeflag = false; dllflag = true; libflag = false; break; case (ConfigurationTypes.typeStaticLibrary): exeflag = false; dllflag = false; libflag = true; break; case (ConfigurationTypes.typeGeneric): //TODO: check what is typeGeneric exeflag = false; dllflag = false; libflag = false; break; default: //ConfigurationTypes.typeUnknown //TODO: throw exception or exit with error exeflag = false; dllflag = false; libflag = false; break; } }
public void GetTypeCode_Returns(string val, ConfigurationTypes type) { var res = TypeHelper.GetTypeCode(val); Assert.AreEqual(type, res); }
public ApplicationConfiguration Get(ConfigurationTypes type) { return(Ctx.ApplicationConfigurations.FirstOrDefault(x => x.Type == type)); }
public Task <ApplicationConfiguration> GetAsync(ConfigurationTypes type) { return(Ctx.ApplicationConfigurations.FirstOrDefaultAsync(x => x.Type == type)); }
public void Execute(GeneratorExecutionContext context) { if (context.SyntaxReceiver is not ConfigurationTemplateInterfaceSyntaxReceiver receiver) { return; } var compilation = context.Compilation; var types = new ConfigurationTypes(compilation); if (!types.CheckContext(context)) { return; } foreach (var ifaceSyntax in receiver.CandidateInterfaces) { var model = compilation.GetSemanticModel(ifaceSyntax.SyntaxTree); var ifaceSymbol = model.GetDeclaredSymbol(ifaceSyntax, context.CancellationToken); if (ifaceSymbol == null) { continue; } if (!ifaceSymbol.GetAttributes() .Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.InputConfigurationAttribute))) { continue; } var diagnostics = Analyzers.AsParallel() .SelectMany(a => a.Analyze(context.Compilation, model, ifaceSyntax, context.CancellationToken)) .ToList(); foreach (var diag in diagnostics) { context.ReportDiagnostic(diag); } if (diagnostics.Any()) { return; } var configProperties = new List <(INamedTypeSymbol, IPropertySymbol)>(); var inputProperties = new List <(INamedTypeSymbol, IPropertySymbol)>(); foreach (var childIface in ifaceSymbol.AllInterfaces.Reverse().Concat(new[] { ifaceSymbol })) { // No need to check if child interfaces are partial because we only add to the root interface. foreach (var member in childIface.GetMembers()) { if (member is IMethodSymbol accessor && accessor.AssociatedSymbol is IPropertySymbol) { continue; } bool isConfigOption = member.GetAttributes() .Where(attr => attr?.AttributeClass? .Equals(types.ConfigurationOptionAttribute, SymbolEqualityComparer.Default) == true) .Any(); bool isInputOption = member.GetAttributes() .Where(attr => attr?.AttributeClass? .Equals(types.InputOptionAttribute, SymbolEqualityComparer.Default) == true) .Any(); // case where neither/both handled by analyzer guards above. if (isConfigOption && member is IPropertySymbol optionProperty) { configProperties.Add((childIface, optionProperty)); } else if (isInputOption && member is IPropertySymbol inputProperty) { inputProperties.Add((childIface, inputProperty)); } } } string classSource = GenerateSource(ifaceSymbol, configProperties, inputProperties, types); context.AddSource($"{ifaceSymbol.Name}_InputConfigurationSection.g.cs", SourceText.From(classSource, Encoding.UTF8)); } }
public override IEnumerable <Diagnostic> Analyze(Compilation compilation, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancel) { var interfaceSyntax = (InterfaceDeclarationSyntax)node; var types = new ConfigurationTypes(compilation); var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceSyntax, cancel); if (interfaceSymbol == null) { yield break; } if (!interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationCollectionAttribute))) { yield break; } var targetAttrs = new List <AttributeData>(); var props = new List <ISymbol>(); foreach (var childIface in interfaceSymbol.AllInterfaces.Reverse().Concat(new[] { interfaceSymbol })) { targetAttrs.AddRange(childIface.GetAttributes() .Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationTargetAttribute))); } // Collect declared root targets var rootTargets = new HashSet <string>(); var sortedTargets = new List <string>(); var leaves = new Queue <string>(); // null target always exists. rootTargets.Add("#null"); // Build root targets foreach (var targetAttr in targetAttrs) { if (targetAttr.ConstructorArguments.Length == 1) { string rootTarget = (string)targetAttr.ConstructorArguments[0].Value !; if (!rootTargets.Contains(rootTarget)) { rootTargets.Add(rootTarget); } } } var adjacency = this.BuildAdjacencyList(rootTargets, targetAttrs); // finding reachable nodes from rootTargets var reachable = new HashSet <string>(rootTargets); var toProcess = new Queue <string>(rootTargets); while (toProcess.Any()) { var targetNode = toProcess.Dequeue(); foreach (var childNodes in adjacency[targetNode]) { reachable.Add(childNodes); toProcess.Enqueue(childNodes); } } foreach (var targetAttr in targetAttrs) { if (targetAttr.ConstructorArguments.Length == 2) { (string childTarget, string parentTarget) = ((string)targetAttr.ConstructorArguments[0].Value !, (string)targetAttr.ConstructorArguments[1].Value !); if (!reachable.Contains(childTarget)) { yield return(Diagnostic.Create(Rule, targetAttr.ApplicationSyntaxReference?.GetSyntax().GetLocation(), childTarget, interfaceSymbol.Name)); } } } }
public override IEnumerable <Diagnostic> Analyze(Compilation compilation, SemanticModel semanticModel, SyntaxNode node, CancellationToken cancel) { var interfaceSyntax = (InterfaceDeclarationSyntax)node; var types = new ConfigurationTypes(compilation); var interfaceSymbol = semanticModel.GetDeclaredSymbol(interfaceSyntax, cancel); if (interfaceSymbol == null) { yield break; } if (!interfaceSymbol.GetAttributes().Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationCollectionAttribute))) { yield break; } var targetAttrs = new List <AttributeData>(); var props = new List <ISymbol>(); foreach (var childIface in interfaceSymbol.AllInterfaces.Reverse().Concat(new[] { interfaceSymbol })) { targetAttrs.AddRange(childIface.GetAttributes() .Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationTargetAttribute))); props.AddRange(childIface.GetMembers().Where(m => m.GetAttributes() .Any(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationTargetMemberAttribute)))); } // Collect pass var targetNames = new HashSet <string>(); // null target is always valid. targetNames.Add("#null"); foreach (var targetAttr in targetAttrs) { if (targetAttr.ConstructorArguments.Length >= 1) { string targetName = (string)targetAttr.ConstructorArguments[0].Value !; if (!targetNames.Contains(targetName)) { targetNames.Add(targetName); } } } foreach (var targetAttr in targetAttrs) { if (targetAttr.ConstructorArguments.Length != 2) { continue; } string parentName = (string)targetAttr.ConstructorArguments[1].Value !; if (!targetNames.Contains(parentName)) { yield return(Diagnostic.Create(Rule, targetAttr.ApplicationSyntaxReference?.GetSyntax().GetLocation(), parentName)); } } foreach (var prop in props) { var memberEntries = prop.GetAttributes() .Where(a => SymbolEqualityComparer.Default.Equals(a.AttributeClass, types.ConfigurationTargetMemberAttribute)); foreach (var entry in memberEntries) { if (entry.ConstructorArguments.Length < 1) { continue; } string targetName = (string)entry.ConstructorArguments[0].Value !; if (!targetNames.Contains(targetName)) { yield return(Diagnostic.Create(Rule, entry.ApplicationSyntaxReference?.GetSyntax().GetLocation(), targetName)); } } } }
public Stt(ConfigurationTypes type, string value) { Type = type; Value = value; }
protected override (INamedTypeSymbol marker, INamedTypeSymbol target) GetAttributes(Compilation compilation) { var types = new ConfigurationTypes(compilation); return(types.GenericTypeAcceptsInputConfigurationAttribute, types.InputConfigurationAttribute); }
public string GenerateCatalog( Workflow workflow, string profileName, string identityName, string validityEnd, string emailAddress, string configurationType) { SelectCustomer.SelectByText(profileName); webDriver.WaitForElementDisplayed( By.XPath("//select[@id='ContentPageHolder_drp_CBC_Identity']/option[text()='" + identityName + "']"), TimeSpan.FromSeconds(10)); IdentityName.SelectByText(identityName); System.Threading.Thread.Sleep(10000); ValidityEnd.SendKeys(validityEnd); EmailAddress.SendKeys(emailAddress); if (workflow == Workflow.Eudc) { if (!string.IsNullOrEmpty(configurationType)) { Console.WriteLine("Configuration Type not provided"); } ClearConfigurationTypes(); if (configurationType.Equals("Standard Configurations")) { ////ConfigurationTypes.ElementAt(0).Click(); javaScriptExecutor.ExecuteScript("arguments[0].click();", ConfigurationTypes.ElementAt(0)); } else if (configurationType.Equals("SNP")) { ////ConfigurationTypes.ElementAt(2).Click(); javaScriptExecutor.ExecuteScript("arguments[0].click();", ConfigurationTypes.ElementAt(2)); } } if (workflow == Workflow.Asn) { if (!ConfigurationTypes.ElementAt(0).Selected) { ////ConfigurationTypes.ElementAt(0).Click(); javaScriptExecutor.ExecuteScript("arguments[0].click();", ConfigurationTypes.ElementAt(0)); } if (!ConfigurationTypes.ElementAt(7).Selected) { ////ConfigurationTypes.ElementAt(7).Click(); javaScriptExecutor.ExecuteScript("arguments[0].click();", ConfigurationTypes.ElementAt(7)); } if (!ConfigurationTypes.ElementAt(2).Selected) { ////ConfigurationTypes.ElementAt(2).Click(); javaScriptExecutor.ExecuteScript("arguments[0].click();", ConfigurationTypes.ElementAt(2)); } if (!ConfigurationTypes.ElementAt(3).Selected) { ////ConfigurationTypes.ElementAt(3).Click(); javaScriptExecutor.ExecuteScript("arguments[0].click();", ConfigurationTypes.ElementAt(3)); } if (!ConfigurationTypes.ElementAt(6).Selected) { ////ConfigurationTypes.ElementAt(6).Click(); javaScriptExecutor.ExecuteScript("arguments[0].click();", ConfigurationTypes.ElementAt(6)); } } ////GenerateCatalogLink.Click(); javaScriptExecutor.ExecuteScript("arguments[0].click();", GenerateCatalogLink); webDriver.WaitForElementDisplayed(By.Id("ContentPageHolder_lbl_TY_ThreadId"), new TimeSpan(0, 0, 10)); return(ThreadId.Text); }