Denis
NuGet package project references
I need to share a project from my solution as a NuGet, to provide base implementation types for my application's plugin system.
Let's call this project
BasePlugin
.
BasePlugin
has project dependencies that must be supplied with the produced NuGet package.
I was able to configure that; the built nuspec
file contains the required project references.
Done based on: https://dev.to/yerac/include-both-nuget-package-references-and-project-reference-dll-using-dotnet-pack-2d8p
However, projects referencing this NuGet cannot access types from the BasePlugin
dependencies.
How do I go about this? Not sure how to search for this.3 replies
✅ Distributed transactions
I'm developing a server + clients suite of applications.
What bothers me is the chance that the client's communication with the server will be interrupted during writes.
Primarily during several interdependent writes, e.g.:
- Create an empty record,
- insert data into the record,
- mark the record as checked-in.
Of course, the simplest thing would be to unify all such processes into one API call, but what if it can be done in smarter way...
I found something about 2PC and SAGA, however, these solutions are tailor-made for microservices, which from my point of view is not quite my case.
I only have client applications that call the server as part of some business process - I can more easily monitor the scope of transactions within the given process.
The goal is that in the event of a technical or business failure, it is possible to:
- Capture, report to the user, and log
- Perform a rollback.
Any suggestions?
15 replies
Sharing PNG/SVG resources between WPF projects
I have a set of images that need to be displayed within my WPF Views.
Assuming I only need and have a single project, adding said resources to it, setting them to
Resource
in the properties, and then referencing via their respective paths is sufficient and works.
E.g.:
1. Create a WPF project
2. Add a folder called Resources
3. Place a PNG image into the Resources folder
4. Set the image item type to be Resource
5. Reference the image via pack://application:,,,/Resources/Color.png
or /MyWPFProjectName;component/Resources/Image.png
Unfortunately, I'm failing to make it work with a multiple projects, where a one of them serves to share images, and the rest reference them (assuming I use a path like /MySharedImageProject;component/Resources/Image.png
).
I'd prefer to have a system similar to how DevExpress does it via a MarkupExtension
: https://docs.devexpress.com/WPF/DevExpress.Xpf.Core.DXImageExtension#remarks
Any pointers you could give me on how to share image resources between projects?1 replies
✅ EF Core include only one property of collection
The expression 'subProject.ProjectId' is invalid inside an 'Include' operation, since it does not represent a property access: 't => t.MyProperty'.How do I query a collection of projects, and only include the ID's of sub-projects instead of complete entities?
5 replies
Unit Testing gRPC server with EF Core
I have an ASP.NET Core gRPC server that exposes several endpoints. Calling these endpoints affects a connected database via EF Core.
How can I effectively test the gRPC endpoints while also mocking the database?
The db is abstracted through an interface.
Let's say my endpoints are:
- CreateGreeting, and
- GetAllGreetings
1 replies
✅ Setting up WPF logging to OTLP collector
My docker compose:
My otel config:
My WPF app config
But... no logs are received by the collector. Why and how do I fix it?
Or at least the running collector instance isn't logging anything when my app is producing logs.
14 replies
✅ Setting up centralized logging for desktop apps
I wish to setup centralized logging using OpenTelemetry.
I'm lost on exporting structured logs from a desktop application.
I have a .NET Server managing database access that exposes gRPC endpoints for clients.
I have .NET desktop Clients (specifically WPF, but this should be irrelevant) that connect to the server via gRPC.
The server and clients shall be installed on-premises; serving these as a cloud SaaS is a future prospect.
I've managed to setup opentelemetry logging for my WPF client; however, I'm clueless as to where and how I should export the collected data.
From my understanding, logs from both the server and clients should be exported to a third service specifically for handling logs. Is this a good approach?
My initial idea was to send logs from clients to the server and then have the server handle the dirty work.
It stemmed from the fact that most guides on setting up OT are for ASP.NET Core applications, that just add an endpoint for sending the collected logs and traces.
To what "system" or service should I export my logs to?
I wish to keep it small and simple, handling around 20 clients and a server and storing logs and metrics for 30 days.
23 replies
✅ Anybody using PostSharp/Metalama?
Before source generators and MVVM toolkit were around, I was looking for ways to simplify my mvvm development. I came across PostSharp.
It was ok to a degree, but the pricing was insane.
Now we have source generators. Aaand, so do they - metalama.
Is anybody using their products? Do you see any benefits? I didn't see a huge advantage then, and I definitely don't see any point in their products now. Especially given the price.
10 replies
✅ Is it possible to explicitly state that a method wont modify a mutable class?
Assume the following class:
I have an instance of said class, and I wish to process it via some method. I want to explicitly state, that this method will not mutate the class instance. is that possible?
E.g., method:
I've looked into freezables, but it doesn't seem like this is relevant for my case.
I'd like to make it clear that:
- I'm aware of read-only properties, I need to keep the property accessors unchanged
- I'm aware of the possibility to pass only the single property value as the method parameter and that strings are immutable, I have more complex classes and I cannot pass each property separately
Thank you for your help!
5 replies
Bogus hierarchical data
Given I have the following class definition
I wish to generate test instances of
Project
using Bogus (https://github.com/bchavez/Bogus).
So, I define a faker like so:
But how do I fake the Parent
property and the SubProjects
property?2 replies
✅ Best practices for WPF context aware documentation
All projects in the company I work at are made in WinForms .NET 4.8 and provide CHM help file documentation.
The new project I'm working on is in WPF .NET 8. And for whatever reason I'm unable to reference the
System.Windows.Forms
reference to access the Help
class necessary for opening the CHMs.
Yes, I can do process open, but I'd love to be able to open the documentation on a specific page, based on context.
So, I've been thinking whether there is a better alternative for application help documentation.
Is there? What would you recommend45 replies
Validating XML files in CSPROJ
I have multiple XML files as project items. These files are filled by developers and are consumed on build by a source generator.
A dev can make a typo in the XML and the generator will fail. Yes, it is possible to introduce XML validation into the generator and outout diagnostics that specify the location of the error.
But, is it possible to do static XML validation via some XSD while it being edited from Visual Studio/Rider without relying on the generator diagnostics? So that the dev has instant feedback on what they are doing wrong, before they even compile.
10 replies
✅ Execute ICommand while button is pressed
In my WPF view I have a 9x9 grid of buttons representing movement controls: up, down, left, right, home.
I wish to press and hold such a button to execute a Viewmodel command until the button is released.
These buttons would serve to move the viewport of a canvas.
Afaik, this isn't possible directly, as a button command is invoked on click. So this will probably require some markup extension to attach to the button events directly; however, my attempts were not fruitful.
How would you implement such a feature?
5 replies
System.Text.Json Source Generators
The JSON serialization can be optimized using source generators.
I understand that I have to write a context for the given class I wish to serialize.
And I'd specify the given context when serializing the class instance.
What I do not understand is how I would pass the context for other classes within the serialized class?
E.g.
Is the context of the
CanvasSettings
including data for the its property members?
How can I utilize source generators when working with polymorphic types?
E.g., IAnimal
, Dog : IAnimal
, Cat : IAnimal
.
Do I write a context for the interface? How would the context cover all the members of the derived classes?3 replies
WPF Custom controls/User controls binding issues and total confusion
need to create a reusable WPF control for displaying plugin settings. There is a defined set of settings, e.g., toggle, combo, file path.
Each of those settings requires its own WPF control.
My initial attempt was to create a User Control, and define a Dependency Property within it:
I set the data context in the constructor to
this
Initially, I've tried using IEnumerable
as a type, but let's stay with this non-collection type for now.
The view of the User control is:
I place my control into my MainWindow.xaml:
But the data is not bound!!!2 replies
❔ User Control with custom dependency properties
I'm developing a user control that is supposed to have two properties bound by a parent control that will be using it.
Initially, I developed the UC like I'm used to - View + ViewModel.
However, I've quickly discovered that I need custom dependency properties that must be written into the View. So, in short, I need help to correctly propagate the bound values back to the ViewModel.
In my Parent ViewModel, I have a
In my parent view, I'm using my custom user control:
UC View-behind:
UC VM property:
UC View:
From my debugging, it seems that the Parent
Templates
property getter is never called, and naturally, the setter of the dependency property is also never called.
Any tips?8 replies
❔ Is it possible to log for the user (not dev) with localization?
Given that a multi-lingual app exists
And it is currently configured to some language
When something is logged via
ILogger
Then the log message is written in the configured language
Is this possible? If so, how?8 replies
✅ How to avoid blocking until all subscribed handlers complete handling an event
I have the following code:
The event handler
WatcherOnCreated
should have very short execution time to avoid overflowing the FileSystemWatcher
buffer.
I'd like to ask what is the most optimal way of avoiding blocking the FSW when handling the event?
I suppose it is running the handler using async void
, but from what I understand the execution is blocked until the WaitForFileAsync
is awaited, right?
Can I await Task.Yield()
in the beginning of ProcessNewMessageAsync
to avoid blocking sooner?13 replies
✅ Correct MVVM approach for displaying models representing settings
Given that I have a set of models representing settings,
When I supply then to a UI utilizing MVVM,
And display each settings with a respective UI component,
Then the user can change the given setting
And the change will be reflected in the model.
As far as I've understood, Models shouldn't really be reactive, i.e., shouldn't implement the
INotifyPropertyChanged
interface.
This goes inline with the motive to keep models very simple, containing primarily properties.
Assume that I have generic models representing, e.g., a Toggle, Text input, Number input, and a Date input settings.
They share the same interface ISettingsElement
, and are exposed to the View via the respective ViewModel.
Displaying specific UI elements based on the provided model is pretty easy.
But how do I make sure that the model values are two-way-bound to the UI elements?
E.g., I wish to display my collection of settings, and provide the user with a Clear
or Defaults
button.
The ViewModel would naturally expose respective ICommand
implementations to do exactly that.
But... going through the Models and modifying their configured values won't be reflected in the UI.
Or, is there a non-hacky way to tell the parent UI control to refresh itself?
All this seems a bit hacky and limiting, when trying to do clean MVVM...
Hopefully, you'll be able to provide me the missing puzzle piece for correctly understading MVVM and implementing the settings feature.115 replies
❔ Quality and free project planning tools
Are there any tools you could recommend for creating and managing use cases, process diagrams, etc?
Preferably free/open source or for a reasonable price.
I currently stupidly rely on word and plantuml :/ pretty horrible for documenting a project
I have some experience with Enterprise architect from university, and I can say that this app is pretty horrendous
2 replies