skip to content
Relatively General .NET

Pasting text without formatting

by Gérald Barré

posted on: October 31, 2022

Google Chrome / Microsoft Edge: Ctrl + Shift + VWindows: Win + V, Then click "…" (see more), Then "Paste as text". To use the keyboard, you can press Tab Enter to select the option:Using Windows PowerToys - Paste as Plain Text: Ctrl + Win + VNote: you can change the shortcut in the configurationMic

C# as a System Language recording

by Oren Eini

posted on: October 26, 2022

In just 20 minutes, I try to condense ~15 years of working on a database engine in C# / .NET and show how you can use C# to build system software. I think it ended up being really nice:

New rules for Blazor in Meziantou.Analyzer

by Gérald Barré

posted on: October 24, 2022

Static analysis is a great way to improve the quality of your code and detect errors before they happen. Blazor has some dynamic parts, so some errors occur only at runtime. In this post, I describe the recent updates in Meziantou.Analyzer to detect some of these errors at compile-time.Meziantou.An

RavenDB indexing

by Oren Eini

posted on: October 20, 2022

When you search for some text in RavenDB, you’ll use case insensitive search by default. This means that when you run this query: You’ll get users with any capitalization of “Oren”. You can ask RavenDB to do a case sensitive search, like so: In this case, you’ll find only exact matches, including casing.  So far, that isn’t really surprising, right? Under what conditions will you need to do searches like that? Well, it is usually when the data itself is case sensitive. User names on Unix are a good example of that, but you may also have Base64 data (where case matters), product keys, etc. What is interesting is that this is a property of the field, usually. Now, how does RavenDB handles this scenario? One option would be to index the data as is and compare it using a case insensitive comparator. That ends up being quite expensive, usually. It’s cheaper by far to normalize the text and compare it using ordinals. The exact() method tells us how the field is supposed to be treated. This is done at indexing time. If we want to be able to query using both case-sensitive and case-insensitive manner, we need to have two fields. Here is what this looks like: We indexed the name field twice, marking it as case sensitive for the second index field. Here is what actually happens behind the scenes because of this configuration:   The analyzer used determines the terms that are generated per index field. The first index field (Name) is using the default LowerCaseKeywordAnalyzer analyzer, while the second index field (ExactName) is using the default exact KeywordAnalyzer analyzer.

Introducing Spectre.Console

by Ardalis

posted on: October 19, 2022

Spectre.Console is a dotnet library for making beautiful, more useful console applications. Here's a quick introduction to getting started…Keep Reading →

Accessing State in System.Text.Json Custom Converters

by Steve Gordon

posted on: October 18, 2022

In this post, I describe several techniques that can provide additional state to custom JsonConverters when using System.Text.Json. While building the new .NET client for Elasticsearch, one of the key objectives I gave myself was to move away from the internal Utf8Json-based serializer used in v7. The obvious choice was to look at redesigning the […]

Join us at QCon San Francisco next week

by Oren Eini

posted on: October 18, 2022

We’ll be in QCon San Francisco next week (Oct 24 – 26), and we’ll be very happy to meet you in person. We are going to show off some of the new features in RavenDB 5.4, discuss what is on the roadmap for RavenDB and present some really cool aspects of what you can do with our database. Trevor Hunter (CTO of @kobo Inc) will present a session on:  Our Journey Into High Performance and Reliable Document Databases with RavenDB. Looking forward to seeing you there.

Error handling in the field

by Oren Eini

posted on: October 17, 2022

I’m not talking about this much anymore, but alongside RavenDB, my company produces a set of tools to help you work with OR/M (object relational mappers) such as NHibernate or Entity Framework as well as tracking what is going on with Cosmos DB. The profilers are implemented as two separate components. We have the Appender, which runs inside the profiled process, and the Profiler, which is a WPF application that analyzes and shows you the results of the profiling. For the profilers, all the execution is done on the users’ machine. We have crash reporting enabled and we are diligent in fixing any and all errors from the field. We recently ran into a whole spate of errors, looking something like this: System.NullReferenceException: Object reference not set to an instance of an object. at System.Windows.Controls.VirtualizingStackPanel.UpdateExtent(Boolean areItemChangesLocal) at System.Windows.Controls.VirtualizingStackPanel.ShouldItemsChangeAffectLayoutCore(Boolean areItemChangesLocal, ItemsChangedEventArgs args) at System.Windows.Controls.VirtualizingPanel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args) at System.Windows.Controls.Panel.OnItemsChanged(Object sender, ItemsChangedEventArgs args) at System.Windows.Controls.ItemContainerGenerator.OnItemAdded(Object item, Int32 index, NotifyCollectionChangedEventArgs collectionChangedArgs) at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args) at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType) at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args) at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) at System.Windows.WeakEventManager.ListenerList`1.DeliverEvent(Object sender, EventArgs e, Type managerType) at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args) at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex) at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at Caliburn.Micro.BindableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item) at Caliburn.Micro.BindableCollection`1.OnUIThread(Action action) at HibernatingRhinos.Profiler.Client.Sessions.SessionListModel.Add(SessionModel model) And here is the relevant code: This is called from a timer thread (not from the UI) one, and the Items collection in this case is a BindableCollection<T>. The error is happening deep in the guts of WPF and it seems like it has been triggered by some recent Windows update. Here is the “fix” for this issue: Basically, don’t report this error, and continue executing normally (the next UI operation will fix the UI state, usually within < 200 ms). This is the right call in terms of development time and effort, but I got to say, this makes me feel quite uncomfortable to see a change like that.