Skip to content

Emit warning or error when using PartialType and IncludeInitializer for the same property #19

Description

@Newex

Imagine the situation:

// Input properties ...
[PartialType(typeof(int))]
[IncludeInitializer]
public string Hello { get; } = "World";

Will produce uncritically (without safeguards):

// Output property: Invalid csharp
public int Hello { get; } = "World";

We can see that the initializer is a string of "Hello World" which is trying to be assigned to an int property.

Why I think this is a good first issue?

I have marked in the PartialIncrementalSourceGenerator.cs file where a check for PartialType and IncludeInitializer has resulted in a true evaluation. The line is marked with a TODO comment. This might / could be a good place to start...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions