Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--update-project feature work #1593

Merged
merged 10 commits into from
Jul 12, 2021
Merged

Conversation

deepchoudhery
Copy link
Member

Draft PR for now.

Will have more incoming changes and tests throughout the review.
Code changes are done through json configs. Only C# files are edited.

Each project type/scenario should have a json config file for itself.

class CodeModifierConfig
{
    public string? Identifier { get; set; } --> identifier for project type/scenario.
    public File[]? Files { get; set; } --> All the files that need editing in the project.
}

class File
{
    public Dictionary<string, Method>? Methods { get; set; } --> all the methods in the file that need editing
    public string[]? Usings { get; set; } --> any `usings` that need to be added to a C# file. 
    public string? FileName { get; set; } --> .cs file to edit
    public string[]? ClassProperties { get; set; } --> any properties that need to be added to the class' members.
    public string[]? ClassAttributes { get; set; } --> [Attribute] that need to added to the class.
}

class Method
{
    public string[]? Parameters { get; set; } --> parameter types for the method. Used to get the correct ParameterSyntax.
    public CodeChange[]? CodeChanges { get; set; } --> All the changes within a particular method.
}
class CodeChange
{
    public string? InsertAfter { get; set; } --> Insert new statement block after this statement syntax node.
    public string? Block { get; set; } --> C# statement that is parsed using SyntaxFactory.ParseStatement
    public string? Parent { get; set; } --> Add C# statement syntax node upon this parent statement syntax node based on Type 
    public string? Type { get; set; } --> CodeChangeType (below) string.
    public bool? Append { get; set; } = false; --> Insert Block at the top of the method.
}

class CodeChangeType
{
    public const string MemberAccess = nameof(MemberAccess); --> Add a SimpleMemberAccess expression to the parent statement syntax. 
    public const string InLambdaBlock = nameof(InBlock); --> Add in lambda block to the parent statement syntax. 
}

This info is also available in CodeModifierConfig folder as well.

The scenarios below need to be supported for all project types :

Scenario Status
ASP .NET Core Web App Config w/out layout(.cshtml) files
ASP .NET Core Web App (w/ B2C tenant) Config w/out layout(.cshtml) files
ASP .NET Core Web Api Config w/out layout(.cshtml) files
ASP .NET Core Web Api (w/ B2C tenant) Config w/out layout(.cshtml) files
Blazor Server App Need config
Blazor Server App (w/ B2C tenant) Need config
Blazor WebAssembly App Need config
Blazor WebAssembly App (w/ B2C tenant) Need config
Blazor Hosted WebAssembly App Need config
Blazor Hosted WebAssembly App (w/ B2C tenant) Need config

@abpiskunov
Copy link
Contributor

    private static void SetUserSecerets(string projectPath, string key, string value, IConsoleLogger consoleLogger)

nit: Secrets


Refers to: src/MSIdentityScaffolding/Microsoft.DotNet.MSIdentity/CodeReaderWriter/CodeWriter.cs:150 in 9a50b7f. [](commit_id = 9a50b7f, deletion_comment = False)

Copy link
Member Author

@deepchoudhery deepchoudhery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@deepchoudhery deepchoudhery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review carried over from #1582

Copy link
Contributor

@abpiskunov abpiskunov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@DamianEdwards DamianEdwards added this to the .NET 6 Preview 7 milestone Jul 9, 2021
deepchoudhery and others added 2 commits July 9, 2021 17:46
* update-project with code changes

* minor fix

* more updates

* minor fixes

* minor fixes

* fixed Resources and other minor fixes
@deepchoudhery deepchoudhery force-pushed the dev/decho/updateProjectCommand branch from 77b76d8 to b097222 Compare July 9, 2021 22:46
@deepchoudhery deepchoudhery merged commit c49241c into main Jul 12, 2021
@deepchoudhery deepchoudhery deleted the dev/decho/updateProjectCommand branch August 13, 2021 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants