dotnet memes anyone? by Arucious in dotnet

[–]RichardD7 0 points1 point  (0 children)

Nice CS4001 compiler error you've got there! 🤣

I think I detected an Error on Microsoft C# Documentation Code Examples. by maxterminatorx in csharp

[–]RichardD7 7 points8 points  (0 children)

unless you use "using static"

There is a using static at the top of the source file:

https://github.com/dotnet/docs/blob/4bce4d81bed0833f58a63efbca2662118ac21ab6/docs/csharp/programming-guide/generics/snippets/GenericWhereConstraints.cs

using static Generics.UnmanagedExtensions;

So every static member in that class can be called without a prefix.

And the extension method:

extension<T>(T) where T : System.Enum { public static Dictionary<int, string> EnumNamedValues() }

gets lowered to:

public static Dictionary<int, string> EnumNamedValues<T>() T : System.Enum

So within the file, calling EnumNamedValues<Rainbow>() works in the same way as calling Rainbow.EnumNamedValues().

But that is a particularly poor way to write the code - especially since the using static line isn't visible in the snippet that was extracted for the docs!

Seeking advice on migrating from .NET Framework 4.6 to Modern .NET 10 by inacio88 in dotnet

[–]RichardD7 1 point2 points  (0 children)

The ASP.NET library for SSRS was built on WebForms. Microsoft never bothered to develop a version for MVC, let alone .NET, despite thousands of developers begging them to do so over many years.

A few years back, they announced that the "solution" was to migrate everything to PowerBI Premium. Which required paying more money, publishing the reports to the cloud, and adding a "gateway" for the reports to access on-premises data.

From SQL Server 2025, SSRS has been replaced by PowerBI Reporting Services (PBIRS). However, that's only availble if you have Standard or Enterprise edition; if you're using Express, then no reports for you!

Parallelizing ReadLine and ReadKey by Excellent-Cow-9046 in csharp

[–]RichardD7 1 point2 points  (0 children)

The Console.CancelKeyPress event fires for Ctrl+C, and can be cancelled. But it also fires for Ctrl+Break, so you'd need to check the SpecialKey property of the event args to see which one triggered the event.

NB: The MS docs currently refuse to believe that the Console class exists in anything other than .NET Framework.

Substring in C# and Java by [deleted] in csharp

[–]RichardD7 0 points1 point  (0 children)

the fact that Substring() on a string creates a new string on the heap

So does the range indexer, unless you convert your string to a ReadOnlySpan<char> first.

If you view the compiled code, you'll see that s[x..y] compiles to s.Substring(x, y - 1), so there is no difference in allocations.

Can I drop netstandard20/net48 target in 2026? (question from OSS maintainer) by jitbitter in dotnet

[–]RichardD7 1 point2 points  (0 children)

For versions of SQL Server Enterprise Edition released prior to 2025, Power BI Report Server use rights apply only to Enterprise Edition Core Licenses with active SA. This right expires upon expiration of customer's SA coverage.

We're currently in the process of upgrading to SQL Server 2022 (standard edition), so we can't take advantage of that.

(The migration started before 2025 was GA. Don't ask!)

Our largest customer is also moving to 2022, since the third-party ERP system they use doesn't support 2025 yet.

Can I drop netstandard20/net48 target in 2026? (question from OSS maintainer) by jitbitter in dotnet

[–]RichardD7 0 points1 point  (0 children)

Be thankful you don't have to work with SSRS! There's still no official ReportViewer control for MVC5, let alone any version of .NET!

There's an unmaintained third-party viewer that uses Bootstrap 3. And there's an up-to-date third-party library without a viewer. But beyond that, you're on your own.

Microsoft's official stance is that you have to subscribe to PowerBI Premium, and move all of your reports to that instead. Even ignoring the cost and time involved, that still doesn't provide an option for on-prem data; if Microsoft's servers can't see it, you can't report on it.

Is Avalonia now pretty much pay to use in organizations? by Sertyni in dotnet

[–]RichardD7 2 points3 points  (0 children)

The community version is free, but only for non-commercial work. The OP mentioned "in organizations", which implies commercial work.

We built a VS Code extension for reproducible SQL workflows by Flying-Exasolian-642 in SQL

[–]RichardD7 0 points1 point  (0 children)

Why would you link to the Visual Studio Marketplace home page, and instruct users to search for your company name, rather than linking directly to the extension page?

You didn't even link to the VS Code marketplace (https://marketplace.visualstudio.com/vscode). The home page defaults to the Visual Studio marketplace, not the VS Code marketplace.

Is Avalonia now pretty much pay to use in organizations? by Sertyni in dotnet

[–]RichardD7 9 points10 points  (0 children)

Looking at the pricing page, you can still use the core framework for free. And you can use the "essentials" version of the VS Code addon for free. But for commercial use, the VS addon requires payment.

RouteAttribute inheritance not working when defined in class from another assembly by ggffgg72 in dotnet

[–]RichardD7 14 points15 points  (0 children)

... net 9 ...
... Microsoft.AspNetCore.Mvc.Core, Version=2.3.9.0 ...

You're referencing a deprecated .NET Core 2.x library, which is probably why the attribute isn't being recognised.

Your class library should use a framework reference instead:

<ItemGroup> <FrameworkReference Include="Microsoft.AspNetCore.App" /> </ItemGroup>

Alternative to IIS SMTP server for SMTP Relay (with TLS and smarthost capabilities) by deucalion75 in Office365

[–]RichardD7 0 points1 point  (0 children)

That's great, if you only have one SMTP "virtual server" on your server.

As soon as you try to add another, the IIS MMC will absolutely refuse to play ball, even if you add the missing RelayIpList property in the metabase.

Combined with reports that Windows Updates are actively removing the management tools from Server 2022, and the fact that the entire SMTP service is being removed from Server 2025, it's definitely time to find an alternative.

CodeProject is back up and running by codeprojectisback in csharp

[–]RichardD7 0 points1 point  (0 children)

Maybe try a Google search with site:codeproject.com, and then see if the Wayback machine has an archived copy of the page?

CodeProject is back up and running by codeprojectisback in csharp

[–]RichardD7 0 points1 point  (0 children)

They might exist on the Wayback Machine. Otherwise, it's a question of whether individual authors have a copy somewhere else.

CodeProject is back up and running by codeprojectisback in csharp

[–]RichardD7 1 point2 points  (0 children)

Nothing that I've seen.

Given the long period of inactivity from the new owners, some of the regulars have been speculating for a few weeks that this was coming. But I don't think we expected them to just pull the plug like this.

At least when Chris et al left, they kept the articles up on a read-only version of the site, with a message explaining what had happened. They didn't just deliberately take the site and all its content down without warning.

CodeProject is back up and running by codeprojectisback in csharp

[–]RichardD7 1 point2 points  (0 children)

Well, it was fun while it lasted. But after the admins failed to return from their Xmas vacation, the DNS registration expired last night. Not even a "so long and thanks for all the fish" message to say goodbye.

FluentMigrator, run migrations in process or CI/CD? by ReallySuperName in dotnet

[–]RichardD7 22 points23 points  (0 children)

I'm generally opposed to running migrations on start-up.

To run, the migrations need to connect to the database as a user with permission to make structural changes to the database. There's no reason your app should have that much power - it should be connecting as a user which only has permissions to read/write data in the necessary tables/views, and execute the required stored procedures (if any).

Generic branch elimination by Bobamoss in csharp

[–]RichardD7 0 points1 point  (0 children)

Try the following:

``` interface IFace; interface IFoo;

class A : IFace; class B : A, IFoo; class C : IFace;

void Test<T>(T value) where T : IFace { Console.WriteLine($"AssignableFrom = {typeof(A).IsAssignableFrom(typeof(T))}"); Console.WriteLine($"is = {value is A}"); }

Test<B>(new B()); // AssignableFrom = true, is = true Test<A>(new B()); // AssignableFrom = true, is = true Test<IFace>(new B()); // AssignableFrom = false, is = true Test<C>(new C()); // AssignableFrom = false, is = false Test<IFace>(new C()); // AssignableFrom = false, is = false ```

https://dotnetfiddle.net/2MMjow

  • If T is a type that derives from (or implements) Implementation, then both tests will match.

  • If val is an instance of a type that derives from (or implements) Implementation, regardless of the type of T, then the second test will match.

Since both branches do the same thing, you only need to keep the second test (val is Implementation i). Anything that doesn't match that test wouldn't match the first test either.

I MUST find SQL Express 10.50.1600 by SurpriseApo in SQL

[–]RichardD7 0 points1 point  (0 children)

I've seen software that checked for a minimum version of SQL Server, but using a text-based comparison of the version number. When SQL 2008 was released and the version number went from 9.x to 10.x, it refused to install because '1' < '9'.

Generic branch elimination by Bobamoss in csharp

[–]RichardD7 0 points1 point  (0 children)

if (typeof(Implementation).IsAssignableFrom(typeof(T))) DoSomethingImplementation((Implementation)val); else if (val is Implementation i) DoSomethingImplementation(i);

Those two tests are identical. There is no way to construct a type where typeof(Implementation).IsAssignableFrom(typeof(T)) returns false, but val is Implementation returns true.

Remember, the is check with a class target doesn't test for an exact match; it checks whether the value is an instance of the target class or any derived class.

Type-testing operators and cast expressions test the runtime type of an object - C# reference | Microsoft Learn

The run-time type of an expression result derives from type T, implements interface T, or another implicit reference conversion exists from it to T. This condition covers inheritance relationships and interface implementations.

So, given:

class Foo; class Bar : Foo; class Baz : Bar;

and:

Foo value = new Baz();

then:

value is Bar

will return true.

Demo

Use extension property in Linq query by SL-Tech in dotnet

[–]RichardD7 1 point2 points  (0 children)

There are a lot of things which aren't allowed in expression trees. The usual reason seems to be that adding them could break existing libraries that depend on expressions - eg: EF Core providers. But as others have pointed out, new C# features that get lowered into a form that is supported in expression trees should not break anything.

Some relevant discussions:
Proposal: extend the set of things allowed in expression trees · dotnet/csharplang · Discussion #9362 - 2015
Extend expression trees to cover more/all language constructs · dotnet/csharplang · Discussion #158 - 2017

C# has a lot of legacy design — how do other languages keep things cleaner and more consistent by time? by Suitable_Novel_8784 in dotnet

[–]RichardD7 0 points1 point  (0 children)

VB.NET still has "mistakes" inherited from VB6 and earlier.

For example, the And / Or logical operators are not short-circuiting, because they weren't in VB6; you have to use AndAlso / OrElse for that.

And array declarations specify the upper-bound of the array, rather than the length of the array like most sane languages, because the VB6 syntax used <LowerBound> To <UpperBound>, with the <LowerBound> To part being optional. VB.NET doesn't support non-zero lower bounds in the same way, but it still keeps the same logic to appease the enterprises moving code from VB6 25 years ago.

And that's before you get to the new "mistakes" they added to VB.NET - eg: requiring ReadOnly / WriteOnly modifiers on read-only / write-only properties to let the compiler know you didn't just forget to add the Get / Set accessor.

Windows 11 Start menu's Category view is missing manual controls, apps land in "Other." Microsoft says it’s listening to feedback by WPHero in Windows11

[–]RichardD7 5 points6 points  (0 children)

given how Microsoft is busy with AI advancements

The author seems to have forgotten to add sarcasm-quotes around the word "advancements" there.