protected override async Task <Document> GetChangedDocumentAsync(CancellationToken cancellationToken) { var languageServices = _document.Project.Solution.Workspace.Services.GetLanguageServices(_state.TypeToGenerateIn.Language); var codeGenerator = languageServices.GetService <ICodeGenerationService>(); var semanticFacts = languageServices.GetService <ISemanticFactsService>(); var value = semanticFacts.LastEnumValueHasInitializer(_state.TypeToGenerateIn) ? EnumValueUtilities.GetNextEnumValue(_state.TypeToGenerateIn, cancellationToken) : null; var syntaxTree = await _document.GetSyntaxTreeAsync(cancellationToken).ConfigureAwait(false); var result = await codeGenerator.AddFieldAsync( _document.Project.Solution, _state.TypeToGenerateIn, CodeGenerationSymbolFactory.CreateFieldSymbol( attributes: default(ImmutableArray <AttributeData>), accessibility: Accessibility.Public, modifiers: default(DeclarationModifiers), type: _state.TypeToGenerateIn, name: _state.IdentifierToken.ValueText, hasConstantValue: value != null, constantValue: value), new CodeGenerationOptions(contextLocation : _state.IdentifierToken.GetLocation()), cancellationToken) .ConfigureAwait(false); return(result); }
protected override async Task <Document> GetChangedDocumentAsync(CancellationToken cancellationToken) { var languageServices = _document.Project.Solution.Workspace.Services.GetLanguageServices(_state.TypeToGenerateIn.Language); var codeGenerator = languageServices.GetService <ICodeGenerationService>(); var semanticFacts = languageServices.GetService <ISemanticFactsService>(); var value = semanticFacts.LastEnumValueHasInitializer(_state.TypeToGenerateIn) ? EnumValueUtilities.GetNextEnumValue(_state.TypeToGenerateIn) : null; var result = await codeGenerator.AddFieldAsync( _document.Project.Solution, _state.TypeToGenerateIn, CodeGenerationSymbolFactory.CreateFieldSymbol( attributes: default,
protected override async Task <Document> GetChangedDocumentAsync(CancellationToken cancellationToken) { var value = _state.TypeToGenerateIn.LastEnumValueHasInitializer() ? EnumValueUtilities.GetNextEnumValue(_state.TypeToGenerateIn, cancellationToken) : null; var result = await new CSharpCodeGenerationService(_document.Project.Solution.Workspace).AddFieldAsync( _document.Project.Solution, _state.TypeToGenerateIn, CodeGenerationSymbolFactory.CreateFieldSymbol( attributes: null, accessibility: Accessibility.Public, modifiers: default(DeclarationModifiers), type: _state.TypeToGenerateIn, name: _state.IdentifierToken.ValueText, hasConstantValue: value != null, constantValue: value), new CodeGenerationOptions(contextLocation: _state.IdentifierToken.GetLocation(), generateDefaultAccessibility: false), cancellationToken) .ConfigureAwait(false); return(result); }