You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
namespace Test;/// <summary>An array indexed by an Enum</summary>/// <typeparam name="TValue">Type stored in array</typeparam>/// <typeparam name="TEnumKey">Indexer Enum type</typeparam>/// If you know your enum does not have much gapps in the value, this will be more efficient than a DictionarypublicstructArrayByEnum<TEnumKey,TValue>:IEnumerable<TValue>whereTEnumKey:Enum// requires C# 7.3 or later{privatereadonly TValue[]_array;privatereadonlyint_lower;publicArrayByEnum(){_lower= Convert.ToInt32(Enum.GetValues(typeof(TEnumKey)).Cast<TEnumKey>().Min());intupper= Convert.ToInt32(Enum.GetValues(typeof(TEnumKey)).Cast<TEnumKey>().Max());_array=new TValue[1+upper-_lower];}public TValue this[TEnumKeykey]{get{return _array[Convert.ToInt32(key)-_lower];}set{ _array[Convert.ToInt32(key)-_lower]=value;}}publicIEnumerator<TValue>GetEnumerator(){varmyThis=this;return Enum.GetValues(typeof(TEnumKey)).Cast<TEnumKey>().Select(i => myThis._array[Convert.ToInt32(i)- myThis._lower]).GetEnumerator();}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()=> GetEnumerator();}
Go to the second-last line.
Invoke the Quick Actions and Refactorings menu:
Press ↓
Wait for it to crash:
Expected Behavior:
A code preview is shown.
Actual Behavior:
ReplaceMethodWithPropertyCodeRefactoringProvider crashes:
System.InvalidOperationException : GetCurrentNode returned null with the following node: foreach (System.Reflection.FieldInfo subfield in fieldValue.GetType().GetFields())
{
Console.WriteLine($" {subfield.Name} = {subfield.GetValue(fieldValue)}");
} - file SyntaxEditor.cs line 255
at Roslyn.Utilities.Contract.Fail(String message,Int32 lineNumber,String filePath)
at Microsoft.CodeAnalysis.Editing.SyntaxEditor.GetChangedRoot()
at async Microsoft.CodeAnalysis.ReplaceMethodWithProperty.ReplaceMethodWithPropertyCodeRefactoringProvider.UpdateReferencesInDocumentAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.ReplaceMethodWithProperty.ReplaceMethodWithPropertyCodeRefactoringProvider.UpdateReferencesAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.ReplaceMethodWithProperty.ReplaceMethodWithPropertyCodeRefactoringProvider.ReplaceMethodsWithPropertyAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputePreviewOperationsAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.CodeActions.CodeAction.GetPreviewOperationsAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.GetPreviewResultAsync(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedActionWithNestedFlavors.<>c__DisplayClass16_0.<GetPreviewAsync>b__0(<Unknown Parameters>)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformFunctionAsync[T](<Unknown Parameters>)
The text was updated successfully, but these errors were encountered:
Version Used: Visual Studio 17.11.0 Preview 1.0
Steps to Reproduce:
Start with the following code:
Expected Behavior:
A code preview is shown.
Actual Behavior:
ReplaceMethodWithPropertyCodeRefactoringProvider crashes:
The text was updated successfully, but these errors were encountered: