Closed davidrimshnick closed 2 years ago
Sorry for a long delay - bad notification settings :(
master
branch if you need only runtime net6
support + few performance improvements.
Build NewDesigner
branch if you additionally need partial designer support.
Build dev
branch if you need both above + more performance improvements.
P.s. We use current dev
in production, so I think it's stable enough...<ItemGroup>
<Reference Include="System.Windows.Forms.DataVisualization">
<HintPath>YOUR_PATH\winforms-datavisualization\src\System.Windows.Forms.DataVisualization\bin\$(Configuration)\$(TargetFramework)\System.Windows.Forms.DataVisualization.dll</HintPath>
</Reference>
</ItemGroup>
And $(TargetFramework)
currently support only net6.0-windows
.
@kirsan31 a little confused with the answer. My project is open source, I assume YOUR_PATH is really where I put in something like C:\.users\someuser\Source\Repos so anyone cloning my project would need to clone yours and change this path in my project file or have I missed something?
@paul1956
@kirsan31 a little confused with the answer. My project is open source, I assume YOUR_PATH is really where I put in something like C:.users\someuser\Source\Repos so anyone cloning my project would need to clone yours and change this path in my project file or have I missed something?
The question was:
What is easiest way to swap this in to my solution?
And the answer above is easiest way in my opinion...
To your question:
<ItemGroup>
<Reference Include="System.Windows.Forms.DataVisualization">
<HintPath>..\winforms-datavisualization\src\System.Windows.Forms.DataVisualization\bin\$(Configuration)\$(TargetFramework)\System.Windows.Forms.DataVisualization.dll</HintPath>
</Reference>
</ItemGroup>
One important note about referencing System.Windows.Forms.DataVisualization
:
currently you need to reference a dll
not the project :( Because of this bug: https://github.com/dotnet/winforms/discussions/7073#discussioncomment-2618159. Unfortunately, I never received an answer from @KlausLoeffelmann on this topic :(
@kirsan31 thanks I had not seen it done with relative paths., super simple thanks, hopefully other issue will be addressed by @KlausLoeffelmann
Great thank you!
Should the visual designer work with this library?
On Tue, Sep 13, 2022 at 2:32 AM kirsan31 @.***> wrote:
Sorry for a long delay - bad notification settings :(
- Clone.
- Build.
- Change reference like this:
YOUR_PATH\winforms-datavisualization\src\System.Windows.Forms.DataVisualization\bin\$(Configuration)\$(TargetFramework)\System.Windows.Forms.DataVisualization.dll And $(TargetFramework) currently support only net6.0-windows.
β Reply to this email directly, view it on GitHub https://github.com/kirsan31/winforms-datavisualization/issues/1#issuecomment-1244960675, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBNXX4QGDYVNC6TYGLSPPLV6ANWVANCNFSM56YBROUQ . You are receiving this because you authored the thread.Message ID: @.***>
Great thank you! Should the visual designer work with this library?
Yes, with some notice that designer still in preview and we have no SDK release yet :( Check here: https://github.com/kirsan31/winforms-datavisualization/issues/3
https://www.nuget.org/packages/Microsoft.WinForms.Designer.SDK/1.1.0-prerelease-preview3.22076.5
https://github.com/KlausLoeffelmann/NetControlDesigners/tree/main/src
And new as of today (and yes, still in work): https://github.com/KlausLoeffelmann/NetControlDesigners/pull/9/files
I also helped Paul to get the template debugged. I am sorry, that I do not have the time, to find the bugs in your projects. I might have some time for that, after the work on the templates and the related docs is finished.
What components are missing for you at this point?
@KlausLoeffelmann
I am sorry, that I do not have the time, to find the bugs in your projects. I might have some time for that, after the work on the
Thank you for just taking the time for us :) Π‘an I ask you to at least take a look at this problem - Designer not work when control referenced by project, but work well if referenced by dll? Because it's very strange and maybe the reason is a bug in the designer... I have opened a new issue with debug details here: https://github.com/kirsan31/winforms-datavisualization/issues/5.
What components are missing for you at this point?
The most problems I faced are absent of editors ArrayEditor
, ColorEditor
, FileNameEditor
etc. And their methods for override EditValue
, ShowHelp
, CreateCollectionForm
etc. And the code itself for these overridden methods looks very simple in this control...
The most problems I faced are absent of editors ArrayEditor, ColorEditor, FileNameEditor etc. And their methods for override EditValue, ShowHelp, CreateCollectionForm etc. And the code itself for these overridden methods looks very simple in this control...
Yes. This is gonna be the MOST effort to get the port done. And I know your personal time is limited right now, because I think I read somewhere your workload is currently comparatively high. But let's try to get this right, and I hope I can support you guys everywhere I will get a spare minute. But it is what it is, and there is a lot of boiler code involved. On the other hand, once you understood how the system works, it's actually not that bad. And @paul1956: We made sure we did the Type Editor templates both in VB and C# - I translated the C# template project after I wrote it to C#. You can take a look at the VB project, it's also in the NetControlDesigner repo I linked to.
Here is my suspicion for the behavior: If the control does need type editors and custom CodeDom Serializers, it needs to be compiled against the SDK for once, and secondly, we need to port the type editors, so they match the requirements for the client and the server parts. Done in every other way, there is at least a big chance the UI will continue to lock up, crash, what have you. Also, error message like we've seen here shouldn't surprise us. And if it's not done the right way, there is a chance it works on one version of the Designer "just so", and the next version kills it of completely because we've changed the internal plumbing.
So, I think it's best to get the project structure done first. Important for chart control in particular: The CodeDom Serializer(s) needs to be working server-side. If they don't, there will be code loss on saving a Form, and that's not the fault of the WinForms Designer. Simplified: The Chart control tells the designer, "Hey, let me do the CodeDom Serialization (so, the writing of the code inside of InitializeComponent
)." And if it then doesn't do it, there will be no code. So, then it seems that the WinForms Designer deletes the code, while in fact the control fails to generate code when it's supposed to be. That's almost always the case, when the Designer seems to be swallowing code: Then, most likely, there will be a custom CodeDom Serializer involved which fails to run.
That is the reason, we also included that aspect of a control's Designer in the templates. So, it's really important to take a look at the templates and read the accompanying readme which I linked to understand what's going on behind the scenes.
Important: If you'd find the time to read that, and you'll have problems in understanding certain aspects of what I wrote, please by all means, kick my butt, so we can improve the text for you and others. This is an important thing to get right, because it is a multiplier, and more customers are enabled to migrate their projects to .NET if their depended 3rd parties get their controls migrated to .NET. I am glad, you can be a part of this, since it's a super important part of extending the WinForms ecosystem on .NET.
One ask that I have: Let's continue the discussion on template topics in the WinForms or the NetControls repo for now. Later this year, we'll hope to open up an additional GitHub repo for SDK specific topics, where we can continue the discussion. Thanks guys, for your involvement here!
- You can reference it as relative path, not absolute. For example (depend on your folders struct of course):
<ItemGroup> <Reference Include="System.Windows.Forms.DataVisualization"> <HintPath>..\winforms-datavisualization\src\System.Windows.Forms.DataVisualization\bin\$(Configuration)\$(TargetFramework)\System.Windows.Forms.DataVisualization.dll</HintPath> </Reference> </ItemGroup>
The control should really be published as a NuGet, and referenced as one. This and this would allow you building a NuGet from command line.
Then you'd want to restructure the solution separating the client, the server and the protocol implementations. You can see examples of a solution structure in https://github.com/KlausLoeffelmann/NetControlDesigners/tree/main/src or https://github.com/RussKie/CustomRootDesigners/tree/custom_cdd.
After that you may be in a position to start building or migrating the editors to be compatible with the out-of-process designer.
@KlausLoeffelmann thank you for explanations. Mainly I was trying to fix/understand https://github.com/kirsan31/winforms-datavisualization/issues/5 bug. I was spent several hours playing with this and I think I'm beginning to understand something... But at the same time, I generally cease to understand how it works now in this (chart) project? How can it work if everything is in one heap in one .Net6 project??? π€¦ββοΈ To begin with, I want to note that all this is very complicated, at least for a person who has never written a complex control with it's own designer π
I found what line of code is responsible of https://github.com/kirsan31/winforms-datavisualization/issues/5. Simplified code:
public override object Serialize(IDesignerSerializationManager manager, object value)
{
Diagnostics.Trace.WriteLine("Context " + manager.Context.Current + "; value " + value);
Chart chart = value as Chart;
object result = null;
CodeDomSerializer baseSerializer = (CodeDomSerializer)manager.GetSerializer(typeof(Chart).BaseType, typeof(CodeDomSerializer));
if (baseSerializer is not null)
{
result = IsSerialized(manager, value) ? GetExpression(manager, value) : baseSerializer.Serialize(manager, value);
if (chart is not null && chart.DataSource is string dSstring && dSstring != "(none)" && result is CodeDom.CodeStatementCollection statements)
{
CodeDom.CodeExpression targetObject = base.SerializeToExpression(manager, value); // the problem in this line!
//if (targetObject is not null)
//{
// CodeDom.CodeAssignStatement assignStatement = new CodeDom.CodeAssignStatement(
// new CodeDom.CodePropertyReferenceExpression(targetObject, "DataSource"),
// new CodeDom.CodePropertyReferenceExpression(new CodeDom.CodeThisReferenceExpression(), dSstring));
// statements.Add(assignStatement);
//}
}
}
return result;
}
With code above we have #5 and Diagnostics line will never appear and DataSource is null
of corse. So Serialize
method simply never called.
If comment out this line:
CodeDom.CodeExpression targetObject = base.SerializeToExpression(manager, value);
we have no https://github.com/kirsan31/winforms-datavisualization/issues/5 problem.
So, my thots that this line (when referenced by project) somehow instructs V.S. to call this code from .net framework (via reflection)???
Also, as I understand from linked repo, that most of the code related to custom editors must be in separate project with net472 target. In our case in this repo all are in same project. Could this be the reason for this (#5) behaviour? I don't understand how it even worked through the dll reference??? π€·ββοΈπ€¦ββοΈ
I wanted to separate all entities as described above. If we had only one property with a custom editor (as in the example), then I think I would have succeeded. I see a lot code in *.Protocol
project for only one costume property! But we have about two hundred of them! This is really a nightmare! Or I missed something? π³
And I also think that articles on how to make a new control for a new designer are good, but we definitely need guides on how to migrate the old control with the least effort. Maybe some sort of helper tool? For example, in my situation - I have a large and complex control, I did not write it, moreover, I did not write my own designers / editors at all. And I need to migrate all this staff to a new designer, to be honest, my hands just drop when I see how complicated / unclear this process is π₯
@RussKie Thank you, but still a lot is not clear :( First of all (as I mentioned above) I totally not understand how does it manage to work now being in one .net6 project???
After that you may be in a position to start building or migrating the editors to be compatible with the out-of-process designer.
Hmmm, I thought that what you described above that's what it is migrating the editors to be compatible with the out-of-process designer. π€·ββοΈ And in my understanding the sequence should be like this:
I'm wrong? Well, the problems of point 1 (in my understanding) I described above.
P.s. And sorry for being not so responsive. With all this situation in my original country, things become very complicated :(
P.s. And sorry for being not so responsive. With all this situation in my original country, things become very complicated :(
Let's try to find ways to support you from here as good as we can! Please reach out to me at klaus dot loeffelmann at microsoft dot com, so we can take your most pressuring issues offline.
Also, don't stress yourself out - I know the new SDK is a lot to take in, but once you got the grip of it, it's actually not too bad. And we are really appreciating the work you've invested into WinForms! Everybody in the team knows your name, and we're keeping your opinion always in our minds when we discuss issues!
We are thinking about better support for this long-term by thinking about introducing code-generators which would be helping with the considerable amount of boiler-plate code. But the task to migrate UI-dependent Control Designer parts for server and client processes remains the same and will always require some additional effort.
Also @merriemcgaw, FYI.
Thank you @KlausLoeffelmann. To summaries all above I have 2 main question for now:
Nuget package added (unlisted, while testing is in progress): https://www.nuget.org/packages/WinForms.DataVisualization/
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
How do I test this? I get the following error.
info : OK https://api.nuget.org/v3-flatcontainer/winforms.datavisualization/1.4.0-pr1/winforms.datavisualization.1.4.0-pr1.nupkg 877ms
error: NU1301: Unable to load the service index for source https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json.
info : Package 'WinForms.DataVisualization' is compatible with all the specified frameworks in project 'C:\Users\PaulM\Source\Repos\CareLink\src\carelink\CareLink.vbproj'.
error: Value cannot be null. (Parameter 'path1')
From: kirsan31 @.> Sent: Friday, November 25, 2022 1:44 PM To: kirsan31/winforms-datavisualization @.> Cc: Paul M Cohen @.>; Mention @.> Subject: Re: [kirsan31/winforms-datavisualization] What is easiest way to swap this in to my solution? (Issue #1) Importance: High
Nuget package added (unlisted, while testing is in progress): https://www.nuget.org/packages/WinForms.DataVisualization/
β Reply to this email directly, view it on GitHub https://github.com/kirsan31/winforms-datavisualization/issues/1#issuecomment-1327690042 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBSM6IRINC5G72XJSEQSXTWKDUFVANCNFSM56YBROUQ . You are receiving this because you were mentioned. https://github.com/notifications/beacon/ADBSM6M6MXGQCABA4WGQE6TWKDUFVA5CNFSM56YBROU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOJ4RPCOQ.gif Message ID: @. @.> >
How do I test this? I get the following error.
As always π€·ββοΈ
<PackageReference Include="WinForms.DataVisualization" Version="1.4.0-pr1" />
And in your log, with my package all are ok:
info : OK https://api.nuget.org/v3-flatcontainer/winforms.datavisualization/1.4.0-pr1/winforms.datavisualization.1.4.0-pr1.nupkg 877ms
the error with:
error: NU1301: Unable to load the service index for source https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json.
And I don't know what is it sorry. π€·ββοΈ -----UPD----- According to this: https://stackoverflow.com/questions/41185443/nuget-connection-attempt-failed-unable-to-load-the-service-index-for-source anything can be the reason....
Power shell like the instructions say
dotnet add package WinForms.DataVisualization --version 1.4.0-pr1
From the project directory
info : OK https://api.nuget.or
g/v3-flatcontainer/winforms.datavisualization/1.4.0-pr1/winforms.datavisualization.1.4.0-pr1.nupkg 877ms
error: NU1301: Unable to load the service index for source https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json.
info : Package 'WinForms.DataVisualization' is compatible with all the specified frameworks in project 'C:\Users\PaulM\Source\Repos\CareLink\src\carelink\CareLink.vbproj'.
error: Value cannot be null. (Parameter 'path1')
From: kirsan31 @.> Sent: Saturday, November 26, 2022 3:48 PM To: kirsan31/winforms-datavisualization @.> Cc: Paul M Cohen @.>; Mention @.> Subject: Re: [kirsan31/winforms-datavisualization] What is easiest way to swap this in to my solution? (Issue #1) Importance: High
How do I test this? I get the following error.
As always π€·ββοΈ https://user-images.githubusercontent.com/17767561/204104405-1aa6021b-35cd-4a84-bf31-5c02c3b5d4ec.png
β Reply to this email directly, view it on GitHub https://github.com/kirsan31/winforms-datavisualization/issues/1#issuecomment-1328096119 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBSM6JRNMA2V43K6KKDXVLWKJLMXANCNFSM56YBROUQ . You are receiving this because you were mentioned. https://github.com/notifications/beacon/ADBSM6ICQM3OUZX73IHQYNLWKJLMXA5CNFSM56YBROU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOJ4USG5Y.gif Message ID: @. @.> >
If I manually add
<PackageReference Include="WinForms.DataVisualization" Version="1.4.0-pr1" />
To project file it works
From: kirsan31 @.> Sent: Saturday, November 26, 2022 3:48 PM To: kirsan31/winforms-datavisualization @.> Cc: Paul M Cohen @.>; Mention @.> Subject: Re: [kirsan31/winforms-datavisualization] What is easiest way to swap this in to my solution? (Issue #1) Importance: High
How do I test this? I get the following error.
As always π€·ββοΈ https://user-images.githubusercontent.com/17767561/204104405-1aa6021b-35cd-4a84-bf31-5c02c3b5d4ec.png
β Reply to this email directly, view it on GitHub https://github.com/kirsan31/winforms-datavisualization/issues/1#issuecomment-1328096119 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBSM6JRNMA2V43K6KKDXVLWKJLMXANCNFSM56YBROUQ . You are receiving this because you were mentioned. https://github.com/notifications/beacon/ADBSM6ICQM3OUZX73IHQYNLWKJLMXA5CNFSM56YBROU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOJ4USG5Y.gif Message ID: @. @.> >
If I manually add
<PackageReference Include="WinForms.DataVisualization" Version="1.4.0-pr1" />
To project file it works
Yea it`s must. It works for me through PowerShell too:
I don't know why he want to download something related to:
https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json.
on you machineπ€·ββοΈ
Hi, thanks for this! What is the best practice for use? Do I clone this repo into my project directory and change the reference somehow? Appreciate the help (more familiar importing nuget packages).