Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@timcassell
Copy link
Collaborator

Fixes #2863

…ntax model for cleaner testing of assignability.

Added BDN1503.
WIP need to do the same for Params.
{
System.Diagnostics.Debugger.Launch();
}
var hasCompilerDiagnostics = HasNoCompilerDiagnostics(string.Format(codeTemplate1, targetType, valueExpression), compilation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be hasNoCompilerDiagnostics :)

var syntaxTreesWithInterceptorsNamespaces = compilation.SyntaxTrees.Where(st => st.Options.Features.ContainsKey(InterceptorsNamespaces));
var syntaxTree = CSharpSyntaxTree.ParseText(code);

var compilerDiagnostics = compilation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you cirmcumvent InterceptorsNamespaces here?

@silkfire
Copy link
Contributor

Didn't quite follow on the reasoning behind removing a lot of the logic for checking assignability. I don't really want to trigger a diagnostic if the user supplies an illegal value to the attribute, e.g. multidimensional arrays string[][], nullable struct arrays int?[] or reference types that aren't null or string or System.Type.

return;
}

#if CODE_ANALYSIS_4_8
Copy link
Contributor

@silkfire silkfire Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever! I wasn't aware you could solve it like this by multi-targeting

if (attributeSyntax.ArgumentList.Arguments.All(aas => aas.NameEquals != null))
{
context.ReportDiagnostic(Diagnostic.Create(MustHaveValuesRule, Location.Create(context.FilterTree, attributeSyntax.ArgumentList.Arguments.Span)));
context.ReportDiagnostic(Diagnostic.Create(MustHaveValuesRule, Location.Create(context.Node.SyntaxTree, attributeSyntax.ArgumentList.Arguments.Span)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've always used context.FilterTree here, is there any difference to context.Node.SyntaxTree?

TypeArgumentClassMustBeNonAbstractRule,
GenericTypeArgumentClassMustBeAnnotatedWithAGenericTypeArgumentsAttributeRule,
];
}.ToImmutableArray();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason why you can't use collection expressions here?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Upgrading from 0.15.6 to 0.15.7 causes compiler mismatch issues

3 participants