RB for VS: Design view BUG with generated code

I tried the trial of Radzen Blazor for Visual Studio, and discovered that the design view does not work on any of the .razor files in my main solution. It appears that it is not compatible with the Hot Chocolate GraphQL server we are using. It appears that the design-time build it uses can’t generate the needed code that is typically generated on normal builds.

DETAILS:

Every design view gives “Design time build failed.” messages, and the output window shows that it is failing with:

C:\Projects\stash\JTemp\JamesWebUI\Server\Program.cs(74,167): error CS1061: 'IRequestExecutorBuilder' does not contain a definition for 'AddJamesGraphQlTypes' and no accessible extension method 'AddJamesGraphQlTypes' accepting a first argument of type 'IRequestExecutorBuilder' could be found (are you missing a using directive or an assembly reference?)

.AddJamesGraphQlTypes(this IRequestExecutorBuilder builder) is an extension method that is generated code created by the "“HotChocolate.Types.Analysers.GraphQLServerGenerator” that runs during normal builds. (Installed via Nuget and is used to support using attributes to set up mutation classes via [MutationType] and type extensions via [ExtendObjectType]) It is called during the initialization of the GraphQL server in our Program.cs of our server application.

Hopefully this gives you enough to recreate the issue. Unfortunately, the application is big enough and proprietary enough to make sending you the source code that causes it difficult. Please let me know if you need additional information.

Hi @Greg_Wilson,

You can try using the C# preprocessor to hide this code from the design-time build.

That got things farther than before. It also appears that it is not compatible with .NET regular expression source generators. Is there any way to make it work without going back to old-fashioned regular expression definitions?

This isn't a known issue. How can we reproduce it?

Just declare one, and the designer will give “error CS8795: Partial method 'MyClass.NineDigitPostalCodePattern()' must have an implementation part because it has accessibility modifiers.”
Example code that causes this:

        [GeneratedRegex(@"^\d{9}$")]
        private static partial Regex NineDigitPostalCodePattern();

I was able to reproduce this when the Regex is defined in a .razor file (or its partial class). It is indeed something we don't support yet. Things seem to work fine if the Regex is defined in a separate class which isn't .razor related. Is this a viable workaround?

We were able to add support for GeneratedRegex attributes in .razor file and it should go live with the very next release.