private static ConstructorDeclarationSyntax CreateConstructor(string identifierText, IEnumerable <MemberDeclarationSyntax> members) { var parameters = new List <ParameterSyntax>(); var statements = new List <ExpressionStatementSyntax>(); foreach (MemberDeclarationSyntax member in members) { string name = GetIdentifier(member).ValueText; string parameterName = Identifier.ToCamelCase(name); statements.Add(ExpressionStatement( SimpleAssignmentExpression( IdentifierName(name), IdentifierName(parameterName)))); parameters.Add(Parameter( default(SyntaxList <AttributeListSyntax>), default(SyntaxTokenList), GetType(member), Identifier(parameterName), default(EqualsValueClauseSyntax))); } return(ConstructorDeclaration( default(SyntaxList <AttributeListSyntax>), ModifierFactory.Public(), Identifier(identifierText), ParameterList(SeparatedList(parameters)), default(ConstructorInitializerSyntax), Block(statements))); }
private static ConstructorDeclarationSyntax CreateConstructor(IMethodSymbol methodSymbol, string name, SemanticModel semanticModel, int position) { var parameters = new List <ParameterSyntax>(); var arguments = new List <ArgumentSyntax>(); foreach (IParameterSymbol parameterSymbol in methodSymbol.Parameters) { EqualsValueClauseSyntax @default = null; if (parameterSymbol.HasExplicitDefaultValue) { @default = EqualsValueClause(DefaultValue(parameterSymbol).WithSimplifierAnnotation()); } parameters.Add(Parameter( default(SyntaxList <AttributeListSyntax>), ModifierFactory.FromAccessibility(parameterSymbol.DeclaredAccessibility), Type(parameterSymbol.Type, semanticModel, position), Identifier(parameterSymbol.Name), @default)); arguments.Add(Argument(IdentifierName(parameterSymbol.Name))); } ConstructorDeclarationSyntax constructor = ConstructorDeclaration( default(SyntaxList <AttributeListSyntax>), ModifierFactory.FromAccessibility(methodSymbol.DeclaredAccessibility), Identifier(name), ParameterList(SeparatedList(parameters)), BaseConstructorInitializer(ArgumentList(arguments.ToArray())), Block()); return(constructor.WithFormatterAnnotation()); }
private IEnumerable <MemberDeclarationSyntax> CreateMembers(IEnumerable <RefactoringInfo> refactorings) { yield return(ConstructorDeclaration("RefactoringsOptionsPage") .WithModifiers(ModifierFactory.Public()) .WithBody(Block(refactorings.Select(refactoring => { return ExpressionStatement( SimpleAssignmentExpression( IdentifierName(refactoring.Identifier), (refactoring.IsEnabledByDefault) ? TrueLiteralExpression() : FalseLiteralExpression())); })))); yield return(MethodDeclaration(VoidType(), "Apply") .WithModifiers(ModifierFactory.Public()) .WithBody( Block(refactorings.Select(refactoring => { return ExpressionStatement( InvocationExpression( "SetIsEnabled", ArgumentList( Argument( SimpleMemberAccessExpression( IdentifierName("RefactoringIdentifiers"), IdentifierName(refactoring.Identifier))), Argument(IdentifierName(refactoring.Identifier))))); })))); foreach (RefactoringInfo info in refactorings) { yield return(CreateRefactoringProperty(info)); } }
private static FieldDeclarationSyntax CreateFieldDeclaration(string name, bool isStatic) { return(FieldDeclaration( (isStatic) ? ModifierFactory.PrivateStaticReadOnly() : ModifierFactory.PrivateReadOnly(), ObjectType(), Identifier(name), ObjectCreationExpression(ObjectType(), ArgumentList()))); }
public override MemberDeclarationSyntax CreateDeclaration() { PropertyKind propertyKind = (SupportsCSharp6) ? PropertyKind.ReadOnlyAutoProperty : PropertyKind.AutoPropertyWithPrivateSet; return(PropertyDeclaration(propertyKind, ModifierFactory.Public(), Type, Name)); }
private void PopulateModifiers() { if (bubbleModifiers == null) { var factory = new ModifierFactory(); bubbleModifiers = new List <BubbleModifier>(factory.CreateAll()); } }
static void Main(string[] args) { // -r "D:\Dropbox\WS\Code\DSQ\Algs\Sort\projs\heapsort - Copy" // -r "D:\Dropbox\WS\Code\DSQ\Algs\Sort\projs\heapsort - Copy" --gt --gtinc "" --gtlibdirs "" --gtdepends "" --ignorelibs "" --gtlibdirsd "" --gtdependsd "" --ignorelibsd "" // -r "D:\Dropbox\WS\Code\DSQ\Algs\Sort\projs\heapsort - Copy" --gt --gtinc "D:\Dropbox\WS\Code\OS\Code.Google\gtest-1.7.0\include" --gtlibdirs "D:\Dropbox\WS\Code\OS\Code.Google\gtest-1.7.0\msvc\gtest-md\Release" --gtdepends "gtest.lib" --ignorelibs "libcpmt.lib;libcmt.lib" --gtlibdirsd "D:\Dropbox\WS\Code\OS\Code.Google\gtest-1.7.0\msvc\gtest-md\Debug" --gtdependsd "gtestd.lib" --ignorelibsd "libcpmtd.lib;libcmtd.lib" var parser = new Parser(with => with.HelpWriter = Console.Error); //if (CommandLine.Parser.Default.ParseArguments(args, options)) //{ // // Values are available here // if (options.SupportGTest) // Console.WriteLine("Include Dir: {0}", options.GTestInclude); //} if (parser.ParseArgumentsStrict(args, options, () => Environment.Exit(-2))) { if (!Directory.Exists(options.RootPath)) { Console.WriteLine("Specific path does not exist."); return; } string searchPatten = "*.*proj"; string[] filePaths = Directory.GetFiles(options.RootPath, searchPatten, SearchOption.AllDirectories); if (filePaths.Length == 0) { Console.WriteLine(string.Format("Didn't find any {0} file under {1}!", searchPatten, options.RootPath)); return; } foreach (var file in filePaths) { Console.WriteLine(string.Format("\nStart to modify settings to file: {0}", file)); ModifierFactory modifierFactory = GetModifierFactory(new FileInfo(file).Extension); if (modifierFactory != null && modifierFactory.CreateModifier().ModifySettings(file, options)) { Console.WriteLine("Successfully modified settings!"); } else { Console.Error.WriteLine("Failed to modify settings!"); } } } }
public CompilationUnitSyntax Generate(IEnumerable <RefactoringDescriptor> refactorings) { return(CompilationUnit() .WithMembers( NamespaceDeclaration(DefaultNamespace) .WithMembers( ClassDeclaration("RefactoringIdentifiers") .WithModifiers(ModifierFactory.PublicStatic()) .WithMembers( CreateMembers(refactorings))))); }
private PropertyDeclarationSyntax CreateRefactoringProperty(RefactoringInfo refactoring) { return(PropertyDeclaration(BoolType(), refactoring.Identifier) .WithAttributeLists( AttributeList(Attribute("Category", IdentifierName("RefactoringCategory"))), AttributeList(Attribute("DisplayName", StringLiteralExpression(refactoring.Title))), AttributeList(Attribute("Description", StringLiteralExpression(CreateDescription(refactoring)))), AttributeList(Attribute("TypeConverter", TypeOfExpression(IdentifierName("EnabledDisabledConverter"))))) .WithModifiers(ModifierFactory.Public()) .WithAccessorList( AccessorList( AutoImplementedGetter(), AutoImplementedSetter()))); }
/// <summary> /// <para>Конструктор. Возвращает экземпляр <see cref="T:GZipTest.GZipModifier"/></para> /// <para>Принимает:</para> <para><paramref name="gZipStreamCommand"></paramref> - /// режим работы <see cref="T:System.IO.Compression.GZipStream"/> /// (<paramref name="gZipStreamCommand"></paramref>)</para> /// <para>полное имя (<paramref name="fileToReadPath"></paramref>) читаемого файла</para> /// <para>полное имя (<paramref name="fileToWritePath"></paramref>) записываемого файла</para> /// </summary> #region constructor public GZipModifier(CompressionMode gZipStreamCommand, string fileToReadPath, string fileToWritePath) { threadsNumber = Environment.ProcessorCount; threadPool = new Thread[threadsNumber]; this.gZipStreamCommand = gZipStreamCommand; this.fileToReadPath = fileToReadPath; this.fileToWritePath = fileToWritePath; args = new string[] { gZipStreamCommand.ToString(), fileToReadPath, fileToWritePath }; fileModifier = ModifierFactory.Create(gZipStreamCommand); readQueue = new LimitedSizeBlocksQueue(threadsNumber); writeBuffer = new ConcurrentDictionary <int, Block>(); countdown = new CountdownEvent(threadsNumber + 1); canAddBlockToBuffer = true; allBlocksWriten = false; blocksReaded = 0; }
public CompilationUnitSyntax Generate(IEnumerable <RefactoringInfo> refactorings) { return(CompilationUnit() .WithUsings(List(new UsingDirectiveSyntax[] { UsingDirective(ParseName(MetadataNames.System_ComponentModel)), UsingDirective(ParseName("Roslynator.CSharp.Refactorings")), UsingDirective(ParseName("Roslynator.VisualStudio.TypeConverters")) })) .WithMembers( NamespaceDeclaration(DefaultNamespace) .WithMembers( ClassDeclaration("RefactoringsOptionsPage") .WithModifiers(ModifierFactory.PublicPartial()) .WithMembers( CreateMembers(refactorings))))); }
private static MethodDeclarationSyntax CreateOnEventMethod( IEventSymbol eventSymbol, ITypeSymbol eventArgsSymbol, bool supportCSharp6) { TypeSyntax eventArgsType = eventArgsSymbol.ToTypeSyntax().WithSimplifierAnnotation(); return(MethodDeclaration( default(SyntaxList <AttributeListSyntax>), (eventSymbol.ContainingType.IsSealed || eventSymbol.ContainingType.IsStruct()) ? ModifierFactory.Private() : ModifierFactory.ProtectedVirtual(), VoidType(), default(ExplicitInterfaceSpecifierSyntax), Identifier($"On{eventSymbol.Name}"), default(TypeParameterListSyntax), ParameterList(Parameter(eventArgsType, Identifier(EventArgsIdentifier))), default(SyntaxList <TypeParameterConstraintClauseSyntax>), Block(CreateOnEventMethodBody(eventSymbol, supportCSharp6)), default(ArrowExpressionClauseSyntax))); }
public void Modifier(ModifierFactory modifier) { Modifiers.Add(modifier); }
public HotelModifierProvider(ModifierFactory <PlayerData, HotelModifierContext> factory) { _factory = factory; }
private static MemberDeclarationSyntax CreateConstantDeclaration(string name) { return(FieldDeclaration(ModifierFactory.PublicConst(), StringType(), name, StringLiteralExpression(name))); }
public override MemberDeclarationSyntax CreateDeclaration() { return(FieldDeclaration(ModifierFactory.PrivateReadOnly(), Type, Name)); }
public static SpellInfo CreateBlock() { return(new SpellInfo(BLOCK_INDEX, BLOCK_CAST_TIME, BLOCK_CAST_TIME, new LinqSpellTargeter((world) => Enumerable.Empty <int>()), new LinqSpellEffect((world, caster, targets) => { if (caster.Mana < BLOCK_MANA) { return; } if (!world.Entities.ContainsKey(caster.ID)) { return; // weird state } world.Entities[caster.ID] = new Entity(caster, mana: caster.Mana - BLOCK_MANA, modifiers: (Maybe <ImmutableList <IModifier> >)caster.Modifiers.Add(ModifierFactory.CreateBlockModifier())); }))); }