Click here to Skip to main content
15,886,919 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralSource Generators in C# and TDD misadventure time Pin
honey the codewitch31-Jan-24 6:30
mvahoney the codewitch31-Jan-24 6:30 
GeneralRe: Source Generators in C# and TDD misadventure time Pin
Graeme_Grant31-Jan-24 21:18
mvaGraeme_Grant31-Jan-24 21:18 
GeneralRe: Source Generators in C# and TDD misadventure time Pin
honey the codewitch1-Feb-24 5:58
mvahoney the codewitch1-Feb-24 5:58 
GeneralRe: Source Generators in C# and TDD misadventure time Pin
Graeme_Grant1-Feb-24 8:31
mvaGraeme_Grant1-Feb-24 8:31 
GeneralCommand line fun in .NET Pin
honey the codewitch27-Jan-24 7:10
mvahoney the codewitch27-Jan-24 7:10 
GeneralRe: Command line fun in .NET Pin
PIEBALDconsult27-Jan-24 7:24
mvePIEBALDconsult27-Jan-24 7:24 
GeneralRe: Command line fun in .NET Pin
honey the codewitch27-Jan-24 7:37
mvahoney the codewitch27-Jan-24 7:37 
GeneralMicrosoft example includes obsolete code: Why? Pin
raddevus25-Jan-24 2:15
mvaraddevus25-Jan-24 2:15 
File this one under Weird (Weird Documentation)

I was looking for a way to read the thumbprint of a X509 Certificate and found a perfect example at:

X509Certificate2.Thumbprint Property (System.Security.Cryptography.X509Certificates) | Microsoft Learn[^]

It's a nice compact sample where you pass in the path to the Cert and it prints out properties of the cert.

However, there's a line in the code that I was curious about:
C#
x509.Import(rawData);

Just Want To Read Properties of Cert
Just wanted to make sure it wasn't importing the cert into my local cert store.
I really don't want to do that. Just want to read properties.

Microsoft Docs On X509.Import
So I looked up the method in the docs (X509Certificate2.Import Method [^])

*Note, if you examine the URL you'll see that it includes view=net-8.0 (assuming that is referencing the latest .net 8.0 docs)

Import Method is Marked Obsolete
But then when you look at the docs the Import method is marked obsolete.
But there doesn't seem to be any mention why.

Since Import just imports the bytes of the certificate (doesn't import it into the cert store -- that is confusing naming)Confused | :confused: I went ahead and ran the sample.

Sample Ran Perfectly Fine
Of course the sample ran fine and served my needs.
But the "obsolete" thing is confusing. Confused | :confused:

Not sure why there isn't a pointer to more updated sample. Confused | :confused: Confused | :confused:
GeneralRe: Microsoft example includes obsolete code: Why? Pin
Bruno van Dooren25-Jan-24 5:28
mvaBruno van Dooren25-Jan-24 5:28 
GeneralRe: Microsoft example includes obsolete code: Why? Pin
raddevus25-Jan-24 8:50
mvaraddevus25-Jan-24 8:50 
GeneralFound an interesting algorithm Pin
honey the codewitch21-Jan-24 5:16
mvahoney the codewitch21-Jan-24 5:16 
GeneralRe: Found an interesting algorithm Pin
Nelek21-Jan-24 6:15
protectorNelek21-Jan-24 6:15 
GeneralRe: Found an interesting algorithm Pin
Greg Utas21-Jan-24 13:32
professionalGreg Utas21-Jan-24 13:32 
GeneralMicrosoft Regex Weirdness Pin
honey the codewitch7-Jan-24 4:17
mvahoney the codewitch7-Jan-24 4:17 
GeneralRe: Microsoft Regex Weirdness Pin
PIEBALDconsult7-Jan-24 5:30
mvePIEBALDconsult7-Jan-24 5:30 
GeneralRe: Microsoft Regex Weirdness Pin
k50547-Jan-24 7:34
mvek50547-Jan-24 7:34 
GeneralRe: Microsoft Regex Weirdness Pin
PIEBALDconsult7-Jan-24 7:59
mvePIEBALDconsult7-Jan-24 7:59 
GeneralRe: Microsoft Regex Weirdness Pin
Brisingr Aerowing7-Jan-24 8:40
professionalBrisingr Aerowing7-Jan-24 8:40 
GeneralRe: Microsoft Regex Weirdness Pin
PIEBALDconsult7-Jan-24 8:58
mvePIEBALDconsult7-Jan-24 8:58 
GeneralRe: Microsoft Regex Weirdness Pin
honey the codewitch7-Jan-24 14:40
mvahoney the codewitch7-Jan-24 14:40 
GeneralRe: Microsoft Regex Weirdness Pin
PIEBALDconsult7-Jan-24 15:34
mvePIEBALDconsult7-Jan-24 15:34 
GeneralRe: Microsoft Regex Weirdness Pin
honey the codewitch7-Jan-24 15:49
mvahoney the codewitch7-Jan-24 15:49 
GeneralRe: Microsoft Regex Weirdness Pin
PIEBALDconsult7-Jan-24 16:35
mvePIEBALDconsult7-Jan-24 16:35 
GeneralRe: Microsoft Regex Weirdness Pin
honey the codewitch7-Jan-24 17:16
mvahoney the codewitch7-Jan-24 17:16 
GeneralRe: Microsoft Regex Weirdness Pin
Peter_in_27807-Jan-24 15:16
professionalPeter_in_27807-Jan-24 15:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.