Skip to content

Code Quality: Use SourceGenerator to simplify DependencyProperty #11587

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

Merged
merged 5 commits into from
May 21, 2023
Merged

Code Quality: Use SourceGenerator to simplify DependencyProperty #11587

merged 5 commits into from
May 21, 2023

Conversation

Poker-sang
Copy link
Contributor

@Poker-sang Poker-sang commented Mar 7, 2023

Use Source Generator to simplify DependencyProperty

Validation
How did you test these changes?

  • Built and ran the app
  • Tested the changes for accessibility

@cinqmilleans
Copy link
Contributor

It's awesome. Let's go one step further and use nameof to avoid typing or editing errors.

[DependencyProperty("ViewModel")]
->
[DependencyProperty(nameof(ViewModel))]

@Poker-sang
Copy link
Contributor Author

It's awesome. Let's go one step further and use nameof to avoid typing or editing errors.

[DependencyProperty("ViewModel")] -> [DependencyProperty(nameof(ViewModel))]

Thank you. But the property ViewModel is also generated, so it cannot be written like this for it is recursive, I believe.

@cinqmilleans
Copy link
Contributor

Yes you are right.

@yaira2 yaira2 changed the title Refactor: Use SourceGenerator to simplify DependencyProperty Code Quality: Use SourceGenerator to simplify DependencyProperty Mar 9, 2023
@yaira2 yaira2 requested a review from d2dyno1 March 9, 2023 04:27
@Poker-sang
Copy link
Contributor Author

Can this PR be approved, or does it need to be modified or something?

@yaira2
Copy link
Member

yaira2 commented Apr 3, 2023

Can this PR be approved, or does it need to be modified or something?

The changes should be discussed with the other contributors first, we started discussing it on Discord but there wasn't a definite conclusion yet.

Copy link
Member

@0x5bfa 0x5bfa left a comment

Choose a reason for hiding this comment

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

I'm on board this introduction.

Probably you need to split up changes into adding Files.SourceGenerator and applying changes because making changes to Files.App will cause file conflists when it takes a lot time to be merged. Can you revert changes in Files.App for the time being(I don't want you to waste)?

Creating a new PR for this and copying files or merging upstream with GitHub Desktop will help you.

@Poker-sang
Copy link
Contributor Author

Ok, I will fix this.

@Poker-sang Poker-sang requested a review from 0x5bfa May 15, 2023 05:58
@Poker-sang Poker-sang closed this May 15, 2023
@Poker-sang Poker-sang deleted the main2 branch May 15, 2023 06:00
@Poker-sang Poker-sang restored the main2 branch May 15, 2023 06:02
@Poker-sang Poker-sang reopened this May 15, 2023
@0x5bfa
Copy link
Member

0x5bfa commented May 15, 2023

Great! I’m sorry for inconvenient.
Can you apply to a variable ‘ViewModel’ in ‘UserControl/PathBreadcrumb.xaml.cs’ so that reviewers always can validate these changes without file conflicts? I was thinking which file is less changed lately. That file is good to go!

The second I confirm beneficial effect, then I will approve the PR

@Poker-sang
Copy link
Contributor Author

Sure

0x5bfa
0x5bfa previously approved these changes May 16, 2023
Copy link
Member

@0x5bfa 0x5bfa left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you!!

@d2dyno1
Copy link
Member

d2dyno1 commented May 16, 2023

I think we can move forward with this until CommunityToolkit adds their own implementation 🙂

@d2dyno1
Copy link
Member

d2dyno1 commented May 16, 2023

Could you also add license info to each file?

@Poker-sang
Copy link
Contributor Author

OK.

@Poker-sang Poker-sang requested a review from d2dyno1 May 17, 2023 01:53
Copy link
Member

@0x5bfa 0x5bfa left a comment

Choose a reason for hiding this comment

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

LGTM!

@0x5bfa 0x5bfa requested a review from hecksmosis May 18, 2023 15:28
Copy link
Contributor

@hecksmosis hecksmosis left a comment

Choose a reason for hiding this comment

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

LGTM

@0x5bfa 0x5bfa requested review from yaira2 and heftymouse May 19, 2023 14:07
@yaira2 yaira2 merged commit 922e528 into files-community:main May 21, 2023
@yaira2 yaira2 added ready to merge Pull requests that are approved and ready to merge and removed needs - code review labels May 21, 2023
@Poker-sang Poker-sang deleted the main2 branch May 21, 2023 02:33
yaira2 added a commit that referenced this pull request May 21, 2023
yaira2 added a commit that referenced this pull request May 21, 2023
@Poker-sang Poker-sang restored the main2 branch May 21, 2023 18:17
@Poker-sang Poker-sang deleted the main2 branch May 23, 2023 02:37
@0x5bfa
Copy link
Member

0x5bfa commented May 28, 2023

@Poker-sang Thank you for contributing to the community! We investigated further and discovered that the app will fail to compile using the x86 & ARM64 configurations. In order to continue releasing updates, it seems that we'll have to revert these changes. We apologize for the inconvenience and we'll be happy to merge the changes once a solution is found.

@Poker-sang
Copy link
Contributor Author

@0x5bfa I'm sorry that my PR took up your time to troubleshoot the problem. But I don't encounter such problem when I use it myself (same with the source generator in CommunityToolkit.Mvvm). Can you tell me how to reproduce this kind of problem for my further improvement?

@0x5bfa
Copy link
Member

0x5bfa commented May 28, 2023

Can you tell me how to reproduce this kind of problem

Building with x86 configuration in Visual Studio.

You can see also the build log here: https://dev.azure.com/filescommunity/Files/_build/results?buildId=19041&view=results

@Poker-sang
Copy link
Contributor Author

It is weird. I have no problems building with x86 config. Do you have any error logs when building with VS or something?
image

@0x5bfa
Copy link
Member

0x5bfa commented May 28, 2023

@yaira2
Copy link
Member

yaira2 commented May 28, 2023

@Poker-sang what happens if you change the build configuration from debug to preview?

@Poker-sang
Copy link
Contributor Author

Poker-sang commented May 28, 2023

@yaira2 I can still successfully build and deploy it (I am using VS2022)
image

@Poker-sang
Copy link
Contributor Author

2023-05-28T05:26:12.8886800Z CompilerServer: server failed - server rejected the request due to analyzer / generator issues 'Could not load file or assembly 'file:///C:\Users\runneradmin\AppData\Local\Temp\VBCSCompiler\AnalyzerAssemblyLoader\ff7d303dfe604105b8be1433d592f9d8\20\Files.SourceGenerator.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format.' - 15c10098-e7ac-4e6f-860e-0c16ce365c0f
2023-05-28T05:26:14.3194118Z CSC : warning CS8034: Unable to load Analyzer assembly D:\a\Files\Files\src\Files.SourceGenerator\bin\x86\Release\netstandard2.0\Files.SourceGenerator.dll : Could not load file or assembly 'file:///D:\a\Files\Files\src\Files.SourceGenerator\bin\x86\Release\netstandard2.0\Files.SourceGenerator.dll' or one of its dependencies. An attempt was made to load a program with an incorrect format. [D:\a\Files\Files\src\Files.App\Files.App.csproj]

Looks like an error occurred with the loaded DLL. Maybe we loaded x64 dll (but we used AnyCPU config)?

@0x5bfa
Copy link
Member

0x5bfa commented May 28, 2023

Reverted changes(in local). Successful.

image

@0x5bfa
Copy link
Member

0x5bfa commented May 28, 2023

Looks like an error occurred with the loaded DLL. Maybe we loaded x64 dll (but we used AnyCPU config)?

Probably. Alghough I added configurations respectively instead of Any CPU and added configuration and pubxml file configuration to the SourceGenerator project, I couldn't make it. Probably, this is referencing issue.

@Poker-sang
Copy link
Contributor Author

Poker-sang commented May 28, 2023

@0x5bfa I appreciate that you can help me so much. My source generator in another project can be build successfully by Github Action. I'm comparing if there was any differences that caused the failure.
https://github.com/Pixeval/Pixeval/blob/main/.github/workflows/build.yml

@Poker-sang
Copy link
Contributor Author

Poker-sang commented May 28, 2023

@yaira2 @0x5bfa The problem is solved. It seems that this is because the solution's platform map is not followed by GitHub action. Thanks for Huo Yaoyuan guidance.
If you add <PlatformTarget>AnyCPU</PlatformTarget> to SourceGenerator.csproj, then the problem is solved.
See: https://github.com/Poker-sang/Files/actions/runs/5103653039/jobs/9174045550

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Pull requests that are approved and ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants