Skip to content
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

Improve partial class support in Blazor #14646

Closed
1 task done
ajaybhargavb opened this issue Oct 1, 2019 · 3 comments
Closed
1 task done

Improve partial class support in Blazor #14646

ajaybhargavb opened this issue Oct 1, 2019 · 3 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components Done This issue has been fixed task

Comments

@ajaybhargavb
Copy link
Contributor

ajaybhargavb commented Oct 1, 2019

Follow up to #5487

@ajaybhargavb ajaybhargavb added the area-blazor Includes: Blazor, Razor Components label Oct 1, 2019
@pranavkm pranavkm added this to the 3.1.0-preview2 milestone Oct 2, 2019
@pranavkm pranavkm added enhancement This issue represents an ask for new feature or an enhancement to an existing one task and removed enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Oct 2, 2019
NTaylorMullen added a commit to dotnet/razor that referenced this issue Oct 10, 2019
- The 3.0 SDK adds RazorDeclaration files to the compile list if they exist. If a user builds in VS and then does a project level operation (adding a property group or item group to their project file) a design time build will trigger for unrelated reasons and declaration files will be included as part of the C# compilation resulting in duplicate member errors. This change ensures that even if declaration files are added we then remove them to ensure we avoid those declaration additions.
- One unfortunate aspect of this change is that declarations are added to the compile list for a brief moment resulting in errors and then are instantly removed in some situations. I say "some situations" because when this happens it is highly dependent on how / when the project system decides to perform a design time build.

dotnet/aspnetcore#14646
NTaylorMullen added a commit to dotnet/razor that referenced this issue Oct 14, 2019
- The 3.0 SDK adds RazorDeclaration files to the compile list if they exist. If a user builds in VS and then does a project level operation (adding a property group or item group to their project file) a design time build will trigger for unrelated reasons and declaration files will be included as part of the C# compilation resulting in duplicate member errors. This change ensures that even if declaration files are added we then remove them to ensure we avoid those declaration additions.
- One unfortunate aspect of this change is that declarations are added to the compile list for a brief moment resulting in errors and then are instantly removed in some situations. I say "some situations" because when this happens it is highly dependent on how / when the project system decides to perform a design time build.

dotnet/aspnetcore#14646
NTaylorMullen added a commit to dotnet/razor that referenced this issue Oct 15, 2019
- We now do aggressive detection on the type of C# class that's being edited. In order to not impact C# scenarios we only do work if C# assets are available to us. Meaning, we inspect the old document and if that document has its' semantic model available we spend cycles to determine if it's a component. In the case that we find a C# component class that wasn't previously caught we enqueue an update.
- Our IComponent detection logic has to be "fuzzy" because we don't have access to the C# compilation at the workspace change detection layer. Therefore we need to look at type names and do string comparisons vs. looking up specific types in the compilation.
- Added several tests to ensure we enqueue and that we properly detect component classes.

dotnet/aspnetcore#14646
NTaylorMullen added a commit to dotnet/razor that referenced this issue Oct 15, 2019
- We now do aggressive detection on the type of C# class that's being edited. In order to not impact C# scenarios we only do work if C# assets are available to us. Meaning, we inspect the old document and if that document has its' semantic model available we spend cycles to determine if it's a component. In the case that we find a C# component class that wasn't previously caught we enqueue an update.
- Our IComponent detection logic has to be "fuzzy" because we don't have access to the C# compilation at the workspace change detection layer. Therefore we need to look at type names and do string comparisons vs. looking up specific types in the compilation.
- Added several tests to ensure we enqueue and that we properly detect component classes.

dotnet/aspnetcore#14646
NTaylorMullen added a commit to dotnet/razor that referenced this issue Oct 15, 2019
- We now do aggressive detection on the type of C# class that's being edited. In order to not impact C# scenarios we only do work if C# assets are available to us. Meaning, we inspect the old document and if that document has its' semantic model available we spend cycles to determine if it's a component. In the case that we find a C# component class that wasn't previously caught we enqueue an update.
- Our IComponent detection logic has to be "fuzzy" because we don't have access to the C# compilation at the workspace change detection layer. Therefore we need to look at type names and do string comparisons vs. looking up specific types in the compilation.
- Added several tests to ensure we enqueue and that we properly detect component classes.

dotnet/aspnetcore#14646
NTaylorMullen added a commit to dotnet/razor that referenced this issue Oct 16, 2019
- The 3.0 SDK adds RazorDeclaration files to the compile list if they exist. If a user builds in VS and then does a project level operation (adding a property group or item group to their project file) a design time build will trigger for unrelated reasons and declaration files will be included as part of the C# compilation resulting in duplicate member errors. This change ensures that even if declaration files are added we then remove them to ensure we avoid those declaration additions.
- One unfortunate aspect of this change is that declarations are added to the compile list for a brief moment resulting in errors and then are instantly removed in some situations. I say "some situations" because when this happens it is highly dependent on how / when the project system decides to perform a design time build.

dotnet/aspnetcore#14646
NTaylorMullen added a commit to dotnet/razor that referenced this issue Oct 16, 2019
- We now do aggressive detection on the type of C# class that's being edited. In order to not impact C# scenarios we only do work if C# assets are available to us. Meaning, we inspect the old document and if that document has its' semantic model available we spend cycles to determine if it's a component. In the case that we find a C# component class that wasn't previously caught we enqueue an update.
- Added several tests to ensure we enqueue and that we properly detect component classes.

dotnet/aspnetcore#14646
NTaylorMullen added a commit to dotnet/razor that referenced this issue Oct 16, 2019
- We now do aggressive detection on the type of C# class that's being edited. In order to not impact C# scenarios we only do work if C# assets are available to us. Meaning, we inspect the old document and if that document has its' semantic model available we spend cycles to determine if it's a component. In the case that we find a C# component class that wasn't previously caught we enqueue an update.
- Added several tests to ensure we enqueue and that we properly detect component classes.

dotnet/aspnetcore#14646
@NTaylorMullen NTaylorMullen added the Done This issue has been fixed label Oct 16, 2019
@rpskelton2
Copy link

rpskelton2 commented Oct 29, 2019

Does this cover inheriting from a generic base class? Last I tried code like below resulted in compiler errors. If I put everything in the .razor file and don't use partial classes it compiles fine.

`

PropertyComponentBase.cs
public abstract class PropertyComponentBase<T> : ComponentBase
{
   blah...
}

MyComponent.razor
@inherits PropertyComponentBase<sometype>

MyComponent.razor.cs
public partial class MyComponent : PropertyComponentBase<sometype>
{
}

@NTaylorMullen
Copy link
Contributor

Works for me so I'd say yes it works 😄

image

@rpskelton2
Copy link

👍

@ghost ghost locked as resolved and limited conversation to collaborators Dec 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components Done This issue has been fixed task
Projects
None yet
Development

No branches or pull requests

4 participants