File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
DevExpress.Mvvm.CodeGenerators.Tests/TestSource
DevExpress.Mvvm.CodeGenerators/Generators Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -406,5 +406,22 @@ public DelegateCommand<int> Command3Command {
406406
407407 }
408408#endif
409+
410+ [ Test , Category ( "TODO" ) ]
411+ public void CommonLanguageVersionTest ( ) {
412+ string source = string . Empty ;
413+ CSharpParseOptions options = new CSharpParseOptions ( ( LanguageVersion ) 1000 ) ; // TODO Change to LanguageVersion.CSharp10
414+ Compilation inputCompilation = CSharpCompilation . Create ( "MyCompilation" ,
415+ new [ ] { CSharpSyntaxTree . ParseText ( source , options ) } ,
416+ new [ ] { MetadataReference . CreateFromFile ( typeof ( object ) . Assembly . Location ) } ,
417+ new CSharpCompilationOptions ( OutputKind . DynamicallyLinkedLibrary ) ) ;
418+ ViewModelGenerator generator = new ViewModelGenerator ( ) ;
419+ GeneratorDriver driver = CSharpGeneratorDriver . Create ( new [ ] { generator } , parseOptions : options ) ;
420+ driver = driver . RunGeneratorsAndUpdateCompilation ( inputCompilation , out var outputCompilation , out var diagnostics ) ;
421+ GeneratorDriverRunResult runResult = driver . GetRunResult ( ) ;
422+ GeneratorRunResult generatorResult = runResult . Results [ 0 ] ;
423+
424+ Assert . AreEqual ( 1 , generatorResult . GeneratedSources . Length ) ;
425+ }
409426 }
410427}
Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ public static void Execute(GeneratorExecutionContext context) {
2020 return ;
2121
2222 SourceText attributesSourceText = SourceText . From ( InitializationGenerator . GetSourceCode ( ContextInfo . GetIsWinUI ( context . Compilation ) ) , Encoding . UTF8 ) ;
23- Compilation compilation = context . Compilation . AddSyntaxTrees ( CSharpSyntaxTree . ParseText ( attributesSourceText ) ) ;
23+ SyntaxTree attributesSyntaxTree = CSharpSyntaxTree . ParseText ( attributesSourceText , ( CSharpParseOptions ) context . ParseOptions ) ;
24+ Compilation compilation = context . Compilation . AddSyntaxTrees ( attributesSyntaxTree ) ;
2425 context . AddSource ( ClassHelper . CreateFileName ( "Attributes" ) , attributesSourceText ) ;
2526
2627 ContextInfo contextInfo = new ContextInfo ( context , compilation ) ;
You can’t perform that action at this time.
0 commit comments