-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing a generic interface IFoo<T>
in both the .razor.cs
and .razor
partial classes for a component can lead to build errors.
#9837
Comments
Hi @rorymcd98, thanks for taking the time to report this. However, I am unable to reproduce the problem from the information provided. I have tried your example with both SDK version 8.0.100 and 6.0.413 in a Note: the error CS0648 is something I would not expect razor compiler to produce, it's something produced usually when you reference a wrongly constructed or corrupted DLL, for example. |
Thanks for the reply @jjonescz, interesting, it must be part of our team's environment then. Several members of our team have reproduced this across Rider and VS. I will try to reproduce it in a fresh project when I get the time. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. Please see our Issue Management Policies for more information. |
@davidwengier FWIW I can reproduce this problem in VS 17.10.0 Preview 5 on net 8 It appears to be a problem in the editor, though, as we can still compile and run fine. When opening a razor file in the editor the errors display as described. The setup to make this happen is a bit more complicated for me, but I can make it happen at will now.
For me, if the inheritance instructions appear in both the To make the error go away, one must remove the inheritance instructions and parameter constraints from the
The error is no longer displayed and the solution still compiles and runs fine. As I understand it, one can specify inheritance and generic parameter constraints in multiple partial class files, as long as they match. This does not seem to be the case in the razor editor. I'm not sure if the issue is the base class, the interface, the generic type params or what, but specifying the inheritance and type parameters in the |
FYI @jjonescz |
Thanks @richardhauer, with your example I can reproduce even in command line builds, investigating. |
Looks like it boils down to a difference in nullability contexts, not sure why it gives such an error, probably a bug in Roslyn. (EDIT: Found a bug that matches this: dotnet/roslyn#40538.) #nullable enable
class C
{
void M()
{
var d = new D<int>(); // error: D<int> is unsupported by the language
}
}
// user's custom partial declaration
public partial class D<T> : I<T> { }
// this is generated by the razor compiler, interfaces are in `#nullable disable` block
public partial class D<T> :
#nullable disable
I<T>
{
}
public interface I<T> { } |
@jjonescz Thank you for investigating and finding a fix! |
Is there an existing issue for this?
Describe the bug
Hopefully this minimal example is clear. This is a blazor wasm component. There is no error appearing in VS or Rider until we attempt to build with either the net6.0.413 or net8.0.0 sdk.
When implementing a generic (must be generic) interrface on both .razor component and .razor.cs partial class we get a build time error.
Removing either
: IFoo<Ti>
or@implements IFoo<Ti>
it builds.Expected Behavior
This should build without a problem.
Steps To Reproduce
Minimal example - implement an interface, which accepts at least one generic type, in both .razor and .razor.cs:
Removing either
: IFoo<Ti>
or@implements IFoo<Ti>
it builds.With
Exceptions (if any)
18>DummyComponent.razor.cs(17,26): Error CS0648 : 'DummyComponent' is a type not supported by the language
.NET Version
6.0.413
Anything else?
.NET SDK (reflecting any global.json):
Version: 6.0.413
Commit: 10710f7d8e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.20348
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.413\
Host:
Version: 8.0.0-preview.7.23375.6
Architecture: x64
Commit: 65b696cf5e
RID: win-x64
.NET SDKs installed:
6.0.413 [C:\Program Files\dotnet\sdk]
7.0.101 [C:\Program Files\dotnet\sdk]
8.0.100-preview.7.23376.3 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.0-preview.7.23375.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.0-preview.7.23375.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.0-preview.7.23376.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
C:\Users\rory.mcdonald\global.json
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
The text was updated successfully, but these errors were encountered: