Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
2e3e331
[release/7.0-rc2] Use determinism instead of timing in cancellation t…
github-actions[bot] Sep 15, 2022
393e1ab
Bump Intellisense RC2 package version again (#75698)
carlossanlop Sep 15, 2022
f0eb5ce
Implement an AppContext compatibility switch re-enabling reflection f…
eiriktsarpalis Sep 16, 2022
fdca698
[release/7.0-rc2] Handle a null szPname field (#75716)
github-actions[bot] Sep 16, 2022
6cf6e48
[wasm] Use newer helix images with updated v8 (#75726)
github-actions[bot] Sep 16, 2022
e0a65e0
Fix edge cases of getting attribute data from syntax (#75728)
github-actions[bot] Sep 16, 2022
e869f44
[release/7.0-rc2] Fix wasm template README (#75766)
github-actions[bot] Sep 16, 2022
b9d050a
Fix Configuration.Binder for collection properties with no setters (#…
github-actions[bot] Sep 16, 2022
5634242
[release/7.0-rc2] Ensure Max/Min for floating-point on x86/x64 are no…
github-actions[bot] Sep 16, 2022
b23dc07
[release/7.0-rc2] Update dependencies from dotnet/emsdk (#75707)
dotnet-maestro[bot] Sep 19, 2022
27396a2
Do not request type layout for RuntimeDetermined types (#75789)
github-actions[bot] Sep 19, 2022
ec82570
Bump 7.0 intellisense package version (WinForms docs update) (#75786)
carlossanlop Sep 19, 2022
39fce88
fix behavior of JMC (#75833)
github-actions[bot] Sep 19, 2022
a66c066
hide interop delegates from intelisense (#75825)
github-actions[bot] Sep 19, 2022
3056135
* fix missing managed stack trace on managed exceptions marshaled to …
pavelsavara Sep 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix edge cases of getting attribute data from syntax (#75728)
Fix two customer-discovered edge cases that were causing analyzer crashes.

Fixes #75681
Fixes #75706

Co-authored-by: Jeremy Koritzinsky <[email protected]>
  • Loading branch information
github-actions[bot] and jkoritzinsky authored Sep 16, 2022
commit e0a65e0713507223165891ba39a999763f31bfd4
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ public static Location FindTypeExpressionOrNullLocation(this AttributeArgumentSy
switch (attributeTarget.Identifier.Kind())
{
case SyntaxKind.ReturnKeyword:
return ((IMethodSymbol)targetSymbol).GetReturnTypeAttributes().First(attributeSyntaxLocationMatches);
if (targetSymbol is IMethodSymbol method)
{
// Sometimes an attribute is put on a symbol that is nested within the containing symbol.
// For example, the ContainingSymbol for an AttributeSyntax on a local function have a ContainingSymbol of the method.
// Since this method is internal and the callers don't care about attributes on local functions,
// we just allow this method to return null in those cases.
return method.GetReturnTypeAttributes().FirstOrDefault(attributeSyntaxLocationMatches);
}
// An attribute on the return value of a delegate type's Invoke method has a ContainingSymbol of the delegate type.
// We don't care about the attributes in this case for the callers, so we'll just return null.
return null;
case SyntaxKind.AssemblyKeyword:
return targetSymbol.ContainingAssembly.GetAttributes().First(attributeSyntaxLocationMatches);
case SyntaxKind.ModuleKeyword:
Expand All @@ -43,7 +53,8 @@ public static Location FindTypeExpressionOrNullLocation(this AttributeArgumentSy
}
}
// Sometimes an attribute is put on a symbol that is nested within the containing symbol.
// For example, the ContainingSymbol for an AttributeSyntax on a parameter have a ContainingSymbol of the method.
// For example, the ContainingSymbol for an AttributeSyntax on a parameter have a ContainingSymbol of the method
// and an AttributeSyntax on a local function have a ContainingSymbol of the containing method.
// Since this method is internal and the callers don't care about attributes on parameters, we just allow
// this method to return null in those cases.
return targetSymbol.GetAttributes().FirstOrDefault(attributeSyntaxLocationMatches);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,18 @@ public class X
{
void Foo([MarshalAs(UnmanagedType.I4)] int i)
{
[return:MarshalAs(UnmanagedType.I4)]
[SkipLocalsInit]
static int Local()
{
return 0;
}
}
}

[return:MarshalAs(UnmanagedType.I4)]
delegate int Y();

""";

await VerifyCS.VerifyAnalyzerAsync(source);
Expand Down