-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrade dependencies * FeatureFormsView (#546) FeatureFormView for WPF * Rename property (#547) * FeatureForm: localized messages (#548) * Add better localizable error messages to form validation and handle null and invalid values better * Prep multiple resources for UWP * Add resource manifest * Fix slashes * Add context to resource strings to help with translations * Undo key rename * Prefix scaleline resource ids * Replace FloorFilter strings with localizable strings * Replace SearchView strings with localizable strings * Add markup extension for localizing strings in XAML * Fix typo * Update maui target versions * Adjust to breaking design changes in FeatureForms API * utilnet: localize trace tool * utilnet: default to empty instead of throw, remove unncessary catch * utilnet: add catch-all to guard against UN failing to load * utilnet: remove localized exception messages though they affect UI. * Handle prop changed events to validation errors (#553) Co-authored-by: Morten Nielsen <mort5161@esri.com> * Handle events firing on background threads * Add missing xmlns mapping for maui * Handle UI Thread-access issue * Update error messages on initial load * Update strings to avoid pluralization issues * Remove BarcodeScannerFormInput (#563) * Hide unsupported inputs + remove unused code * Handle visibility changes coming from background thread * Update validation as you type * Adds an analyzer that detects whether UseArcGISToolkit has been added (#556) * Adds an analyzer that detects whether UseArcGISToolkit has been added * FeatureForm WPF: Tooltip shows even when empty (#561) * Adding Visibility toggle based on content of `Hint` Property using VisibilityConverter * Changing Tooltip visibility code from ValueConverter to Triggers. * Don't sign unpackable targets Ensure only packable projects gets signed. If built with `GeneratePackageOnBuild=true` this command would run and fail. * FeatureForms for .NET MAUI (#564) * Initial skeleton for maui feature forms * SwitchInput added * Added text inputs * Add error border to text fields * Added place holders for remaining input types * Implement combobox * Add radio button support * Clean up * Update enable state * Add group expander * Maui: Update switch enable state * Improve group UI * Style fixes * indent * More styling tweaks * Show 0 length for null strings * Improve switch * Add IsValid property to MAUI * ui fixes * Move guarded evaluate to FeatureFormView and also use it on initialize to avoid more cancellation exceptions * Improve group rendering * Improve group box UI * Use TextBlock instead to show readonly text + Don't show error messages when a field isn't editable * Use extension method for dispatching * Rename files * Use unicode * Remove unused code * Preserve property * Missing preserves * Fix type * Add missing INT64 * Add FFV doc * Update doc * Include all language resources on MAUI and WinUI as well * feat(localization): update pseudo translation (#557) * Update translation - @mit10976 @Isa13169 @nia13404 * Add FeatureFormView sample * MAUI: Add DateTimePickerFormInput (#565) * wpf: Improve keyboard navigation for FeatureForms (#567) * Use updated URLs * Fix version * Fix typo --------- Co-authored-by: Morten Nielsen <mort5161@esri.com> Co-authored-by: Matvei Stefarov <mstefarov@esri.com> Co-authored-by: Jennifer Nery <jnery@esri.com> Co-authored-by: Prathamesh Narkhede <55591622+prathameshnarkhede@users.noreply.github.com> Co-authored-by: Isaac Sesmundo <isesmundo@esri.com>
- Loading branch information
1 parent
5a3260c
commit fbea93f
Showing
144 changed files
with
21,840 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# FeatureFormView | ||
|
||
Generates an interactive form from a [FeatureFormDefinition](https://developers.arcgis.com/net/api-reference/api/netwin/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Mapping.FeatureForms.FeatureFormDefinition.html). | ||
|
||
![image](https://github.com/Esri/arcgis-maps-sdk-dotnet-toolkit/assets/1378165/ff655fac-9eae-48ce-a044-588a2e32afa8) | ||
|
||
## Features | ||
|
||
- Supports interactive editing of Features through text, checkboxes, comboboxes, switches etc. | ||
|
||
## Usage | ||
|
||
FeatureFormView displays a feature from using an underlying [`FeatureForm`](https://developers.arcgis.com/net/api-reference/api/netwin/Esri.ArcGISRuntime/Esri.ArcGISRuntime.Mapping.FeatureForms.FeatureForm.html). | ||
|
||
|
||
The following code shows how to get a `Feature` and its `FeatureFormDefinition` from an identify result: | ||
|
||
```cs | ||
private ArcGISFeature? GetFeature(IEnumerable<IdentifyLayerResult> results, out FeatureFormDefinition? definition) | ||
{ | ||
def = null; | ||
if (results == null) | ||
return null; | ||
foreach (var result in results.Where(r => r.LayerContent is FeatureLayer layer && (layer.FeatureFormDefinition is not null || (layer.FeatureTable as ArcGISFeatureTable)?.FeatureFormDefinition is not null))) | ||
{ | ||
var feature = result.GeoElements?.OfType<ArcGISFeature>()?.FirstOrDefault(); | ||
def = (result.LayerContent as FeatureLayer)?.FeatureFormDefinition ?? ((result.LayerContent as FeatureLayer)?.FeatureTable as ArcGISFeatureTable)?.FeatureFormDefinition; | ||
if (feature != null && def != null) | ||
{ | ||
return feature; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
``` | ||
|
||
The following code shows how to get a `FeatureForm` from a `FeatureFormDefinition` and an `ArcGISFeature`: | ||
|
||
```cs | ||
var featureForm = new FeatureForm(feature, definition); | ||
``` | ||
|
||
To display a `FeatureForm` in the UI: | ||
|
||
```xml | ||
<esri:FeatureFormView x:Name="featureFormView" /> | ||
``` | ||
|
||
|
||
To present a `FeatureForm` in a `FeatureFormView`: | ||
|
||
```cs | ||
featureFormView.FeatureForm = featureForm; | ||
``` | ||
|
||
To apply the edits, you can make your own buttons and allow users to submit or discard edits. | ||
|
||
```xml | ||
<Button Content="Discard" Click="DiscardButton_Click" /> | ||
<Button Content="Apply" Click="ApplyButton_Click" IsEnabled="{Binding IsValid, ElementName=featureFormView}" /> | ||
``` | ||
```cs | ||
private void DiscardButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
var result = MessageBox.Show("Discard edits?", "Confirm", MessageBoxButton.YesNo); | ||
if(result == MessageBoxResult.Yes) | ||
formViewer.FeatureForm.DiscardEdits(); | ||
} | ||
private async void ApplyButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
// Collect all errors to display to the user (If you disable the button with the above 'IsValid' binding expression this step isn't necessary) | ||
// Note that often you'll still be able to apply edits ignoring the feature form's set of rules, as long as those rules don't violate the underlying table schema. | ||
var errors = await formViewer.FeatureForm.EvaluateExpressionsAsync(); //Ensure all expressions are fully evaluated. | ||
var errorList = formViewer.FeatureForm.Elements.OfType<FieldFormElement>().SelectMany(s => s.ValidationErrors).Concat(errors); | ||
if (errorList.Any()) | ||
{ | ||
MessageBox.Show("Form has errors:\n" + string.Join("\n", errorList.Select(e => e.Message)), "Can't apply"); | ||
return; | ||
} | ||
try | ||
{ | ||
await formViewer.FeatureForm.Feature.FeatureTable.UpdateFeatureAsync(formViewer.FeatureForm.Feature); | ||
} | ||
catch (Exception ex) | ||
{ | ||
MessageBox.Show("Failed to apply edits:\n" + ex.Message, "Error"); | ||
} | ||
} | ||
``` |
26 changes: 26 additions & 0 deletions
26
src/Analyzers/Toolkit.Analyzers.Test/Esri.ArcGISRuntime.Toolkit.Analyzers.Test.projitems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' < '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects> | ||
<HasSharedItems>true</HasSharedItems> | ||
<SharedGUID>61fbc238-623c-42ff-8c47-95d710a1e66f</SharedGUID> | ||
</PropertyGroup> | ||
<PropertyGroup Label="Configuration"> | ||
<Import_RootNamespace>Esri.ArcGISRuntime.Toolkit.Analyzers.Test</Import_RootNamespace> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpAnalyzerVerifier`1+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpAnalyzerVerifier`1.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpCodeFixVerifier`2+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpCodeFixVerifier`2.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpCodeRefactoringVerifier`1+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpCodeRefactoringVerifier`1.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\CSharpVerifierHelper.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicAnalyzerVerifier`1+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicAnalyzerVerifier`1.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicCodeFixVerifier`2+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicCodeFixVerifier`2.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicCodeRefactoringVerifier`1+Test.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)Verifiers\VisualBasicCodeRefactoringVerifier`1.cs" /> | ||
</ItemGroup> | ||
</Project> |
13 changes: 13 additions & 0 deletions
13
src/Analyzers/Toolkit.Analyzers.Test/Esri.ArcGISRuntime.Toolkit.Analyzers.Test.shproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>61fbc238-623c-42ff-8c47-95d710a1e66f</ProjectGuid> | ||
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion> | ||
</PropertyGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" /> | ||
<PropertyGroup /> | ||
<Import Project="Esri.ArcGISRuntime.Toolkit.Analyzers.Test.projitems" Label="Shared" /> | ||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" /> | ||
</Project> |
26 changes: 26 additions & 0 deletions
26
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpAnalyzerVerifier`1+Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpAnalyzerVerifier<TAnalyzer> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
{ | ||
public class Test : CSharpAnalyzerTest<TAnalyzer, MSTestVerifier> | ||
{ | ||
public Test() | ||
{ | ||
SolutionTransforms.Add((solution, projectId) => | ||
{ | ||
var compilationOptions = solution.GetProject(projectId).CompilationOptions; | ||
compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( | ||
compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); | ||
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); | ||
return solution; | ||
}); | ||
} | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpAnalyzerVerifier`1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpAnalyzerVerifier<TAnalyzer> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
{ | ||
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic()"/> | ||
public static DiagnosticResult Diagnostic() | ||
=> CSharpAnalyzerVerifier<TAnalyzer, MSTestVerifier>.Diagnostic(); | ||
|
||
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic(string)"/> | ||
public static DiagnosticResult Diagnostic(string diagnosticId) | ||
=> CSharpAnalyzerVerifier<TAnalyzer, MSTestVerifier>.Diagnostic(diagnosticId); | ||
|
||
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.Diagnostic(DiagnosticDescriptor)"/> | ||
public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) | ||
=> CSharpAnalyzerVerifier<TAnalyzer, MSTestVerifier>.Diagnostic(descriptor); | ||
|
||
/// <inheritdoc cref="AnalyzerVerifier{TAnalyzer, TTest, TVerifier}.VerifyAnalyzerAsync(string, DiagnosticResult[])"/> | ||
public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) | ||
{ | ||
var test = new Test | ||
{ | ||
TestCode = source, | ||
}; | ||
|
||
test.ExpectedDiagnostics.AddRange(expected); | ||
await test.RunAsync(CancellationToken.None); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpCodeFixVerifier`2+Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Microsoft.CodeAnalysis.CodeFixes; | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
using System.Numerics; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpCodeFixVerifier<TAnalyzer, TCodeFix> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
where TCodeFix : CodeFixProvider, new() | ||
{ | ||
public class Test : CSharpCodeFixTest<TAnalyzer, TCodeFix, MSTestVerifier> | ||
{ | ||
public Test() | ||
{ | ||
SolutionTransforms.Add((solution, projectId) => | ||
{ | ||
var compilationOptions = solution.GetProject(projectId).CompilationOptions; | ||
compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( | ||
compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); | ||
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); | ||
return solution; | ||
}); | ||
} | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpCodeFixVerifier`2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CodeFixes; | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpCodeFixVerifier<TAnalyzer, TCodeFix> | ||
where TAnalyzer : DiagnosticAnalyzer, new() | ||
where TCodeFix : CodeFixProvider, new() | ||
{ | ||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic()"/> | ||
public static DiagnosticResult Diagnostic() | ||
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, MSTestVerifier>.Diagnostic(); | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic(string)"/> | ||
public static DiagnosticResult Diagnostic(string diagnosticId) | ||
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, MSTestVerifier>.Diagnostic(diagnosticId); | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.Diagnostic(DiagnosticDescriptor)"/> | ||
public static DiagnosticResult Diagnostic(DiagnosticDescriptor descriptor) | ||
=> CSharpCodeFixVerifier<TAnalyzer, TCodeFix, MSTestVerifier>.Diagnostic(descriptor); | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyAnalyzerAsync(string, DiagnosticResult[])"/> | ||
public static async Task VerifyAnalyzerAsync(string source, params DiagnosticResult[] expected) | ||
{ | ||
var test = new Test | ||
{ | ||
TestCode = source, | ||
}; | ||
|
||
test.ExpectedDiagnostics.AddRange(expected); | ||
await test.RunAsync(CancellationToken.None); | ||
} | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, string)"/> | ||
public static async Task VerifyCodeFixAsync(string source, string fixedSource) | ||
=> await VerifyCodeFixAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, DiagnosticResult, string)"/> | ||
public static async Task VerifyCodeFixAsync(string source, DiagnosticResult expected, string fixedSource) | ||
=> await VerifyCodeFixAsync(source, new[] { expected }, fixedSource); | ||
|
||
/// <inheritdoc cref="CodeFixVerifier{TAnalyzer, TCodeFix, TTest, TVerifier}.VerifyCodeFixAsync(string, DiagnosticResult[], string)"/> | ||
public static async Task VerifyCodeFixAsync(string source, DiagnosticResult[] expected, string fixedSource) | ||
{ | ||
var test = new Test | ||
{ | ||
TestCode = source, | ||
FixedCode = fixedSource, | ||
}; | ||
|
||
test.ExpectedDiagnostics.AddRange(expected); | ||
await test.RunAsync(CancellationToken.None); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpCodeRefactoringVerifier`1+Test.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.CodeAnalysis.CodeRefactorings; | ||
using Microsoft.CodeAnalysis.CSharp.Testing; | ||
using Microsoft.CodeAnalysis.Testing.Verifiers; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpCodeRefactoringVerifier<TCodeRefactoring> | ||
where TCodeRefactoring : CodeRefactoringProvider, new() | ||
{ | ||
public class Test : CSharpCodeRefactoringTest<TCodeRefactoring, MSTestVerifier> | ||
{ | ||
public Test() | ||
{ | ||
SolutionTransforms.Add((solution, projectId) => | ||
{ | ||
var compilationOptions = solution.GetProject(projectId).CompilationOptions; | ||
compilationOptions = compilationOptions.WithSpecificDiagnosticOptions( | ||
compilationOptions.SpecificDiagnosticOptions.SetItems(CSharpVerifierHelper.NullableWarnings)); | ||
solution = solution.WithProjectCompilationOptions(projectId, compilationOptions); | ||
return solution; | ||
}); | ||
} | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Analyzers/Toolkit.Analyzers.Test/Verifiers/CSharpCodeRefactoringVerifier`1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Microsoft.CodeAnalysis.CodeRefactorings; | ||
using Microsoft.CodeAnalysis.Testing; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Esri.ArcGISRuntime.Toolkit.Analyzers.Test | ||
{ | ||
public static partial class CSharpCodeRefactoringVerifier<TCodeRefactoring> | ||
where TCodeRefactoring : CodeRefactoringProvider, new() | ||
{ | ||
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, string)"/> | ||
public static async Task VerifyRefactoringAsync(string source, string fixedSource) | ||
{ | ||
await VerifyRefactoringAsync(source, DiagnosticResult.EmptyDiagnosticResults, fixedSource); | ||
} | ||
|
||
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, DiagnosticResult, string)"/> | ||
public static async Task VerifyRefactoringAsync(string source, DiagnosticResult expected, string fixedSource) | ||
{ | ||
await VerifyRefactoringAsync(source, new[] { expected }, fixedSource); | ||
} | ||
|
||
/// <inheritdoc cref="CodeRefactoringVerifier{TCodeRefactoring, TTest, TVerifier}.VerifyRefactoringAsync(string, DiagnosticResult[], string)"/> | ||
public static async Task VerifyRefactoringAsync(string source, DiagnosticResult[] expected, string fixedSource) | ||
{ | ||
var test = new Test | ||
{ | ||
TestCode = source, | ||
FixedCode = fixedSource, | ||
}; | ||
|
||
test.ExpectedDiagnostics.AddRange(expected); | ||
await test.RunAsync(CancellationToken.None); | ||
} | ||
} | ||
} |
Oops, something went wrong.