Closed dsaveyn closed 2 years ago
It keeps coming back! See original https://github.com/microsoft/AL/issues/6558 and my new https://github.com/microsoft/AL/issues/6891
No repro.
Repro!
The OP's mentioned "attachments" were missing, but I managed to recreate a minimal scenario that shows their problem.
report 50100 Test
{
dataset
{
dataitem(Customer; Customer)
{
trigger OnPreDataItem()
var
Customer: record "Customer";
begin
Customer.SetLoadFields(Name);
RequestOptionsPage.Update(); // This line causes the analyzer to throw an exception
end;
}
}
requestpage
{ }
}
uncommented: borked
Analyzer 'Microsoft.Dynamics.Nav.CodeCop.Design.Rule0242PartialRecordsDetectJitLoads' threw an exception of type 'System.InvalidCastException' with message 'System.InvalidCastException: Unable to cast object of type 'Microsoft.Dynamics.Nav.CodeAnalysis.BoundObjectAccess' to type 'Microsoft.Dynamics.Nav.CodeAnalysis.IFieldAccess'.
at Microsoft.Dynamics.Nav.CodeAnalysis.OperationExtensions.GetSymbol(IOperation operation) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\OperationExtensions.cs:line 41
at Microsoft.Dynamics.Nav.CodeCop.Design.Rule0242PartialRecordsDetectJitLoads.JitLoadDetectionVisitor.VisitInvocationExpression(IInvocationExpression operation) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule0242PartialRecordsDetectJitLoads.cs:line 255
at Microsoft.Dynamics.Nav.CodeAnalysis.OperationWalker.Visit(IOperation operation) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\OperationWalker.cs:line 36
at Microsoft.Dynamics.Nav.CodeAnalysis.OperationWalker.Visit(IOperation operation) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\OperationWalker.cs:line 36
at Microsoft.Dynamics.Nav.CodeAnalysis.OperationWalker.VisitArray[T](ImmutableArray`1 list) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\OperationWalker.cs:line 44
at Microsoft.Dynamics.Nav.CodeAnalysis.OperationWalker.VisitBlockStatement(IBlockStatement operation) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\OperationWalker.cs:line 49
at Microsoft.Dynamics.Nav.CodeAnalysis.BoundBlock.Accept(OperationVisitor visitor) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\BoundTree\Statements.cs:line 84
at Microsoft.Dynamics.Nav.CodeAnalysis.OperationWalker.Visit(IOperation operation) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\OperationWalker.cs:line 36
at Microsoft.Dynamics.Nav.CodeCop.Design.Rule0242PartialRecordsDetectJitLoads.AnalyzeMethod(OperationAnalysisContext context) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeCop\Design\Rule0242PartialRecordsDetectJitLoads.cs:line 128
at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.<>c__DisplayClass53_1.<ExecuteOperationAction>b__1() in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 764
at Microsoft.Dynamics.Nav.CodeAnalysis.Diagnostics.AnalyzerExecutor.ExecuteAndCatchIfThrows_NoLock(DiagnosticAnalyzer analyzer, Action analyze, Nullable`1 info) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\DiagnosticAnalyzer\AnalyzerExecutor.cs:line 1100'
commented: works
Name: AL Language
Id: ms-dynamics-smb.al
Description: AL development tools for Dynamics 365 Business Central
Version: 8.2.552672
Publisher: Microsoft
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al
It isn't reproducing in the dev branch since it was already fixed. It seems it wasn't backported to release branch, will do that now.
Thanks!
Please include the following with each issue:
1. Describe the bug A SetLoadFields() call followed by a RequestOptionsPage.Update() call causes the analyzer to throw the following exception:
2. To Reproduce Steps to reproduce the behavior:
Note: Because the developers need to copy and paste the code snippet, including a code snippet as a media file (i.e. .gif) is not sufficient.
3. Expected behavior The code analyzer should not thrown an exception
4. Actual behavior The code analyzer throws an exception:
5. Versions:
Final Checklist
Please remember to do the following:
[ ] Search the issue repository to ensure you are reporting a new issue
[ ] Reproduce the issue after disabling all extensions except the AL Language extension
[ ] Simplify your code around the issue to better isolate the problem