Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit dc058f2

Browse files
authored
Generate source for .resx files on build. (dotnet#3607)
* add build task to generate *.fs from *.resx files * generate source for embedded resources in tests * generate source for embedded resources in FSharp.Editor * generate source for embedded resources in FSharp.LanguageService * generate source for embedded resources in FSharp.ProjectSystem.FSharp * generate source for embedded resources in FSharp.VS.FSI * don't generate non-string resources when <=netstandard1.6 * update baseline error message for tests The error output should be the exception message, not the exception type. * perform up-to-date check before generating *.fs from *.resx * remove non-idiomatic fold for an array comprehension * correct newline replacement * output more friendly error message * throw if boolean value isn't explicitly `true` or `false` * only generate object resource code on non `netstandard1.*` and `netcoreapp1.*` platforms * ensure FSharp.Core specifies a target framework for resource generaton * rename attributes to be non-ambiguous and properly include them
1 parent 7426871 commit dc058f2

15 files changed

+67
-108
lines changed

Classification/ClassificationDefinitions.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ module internal ClassificationDefinitions =
140140
type internal FSharpFunctionTypeFormat() as self =
141141
inherit ClassificationFormatDefinition()
142142

143-
do self.DisplayName <- SR.FSharpFunctionsOrMethodsClassificationType.Value
143+
do self.DisplayName <- SR.FSharpFunctionsOrMethodsClassificationType()
144144

145145
[<Export(typeof<EditorFormatDefinition>)>]
146146
[<ClassificationType(ClassificationTypeNames = FSharpClassificationTypes.MutableVar)>]
@@ -150,7 +150,7 @@ module internal ClassificationDefinitions =
150150
type internal FSharpMutableVarTypeFormat [<ImportingConstructor>](theme: ThemeColors) as self =
151151
inherit ClassificationFormatDefinition()
152152

153-
do self.DisplayName <- SR.FSharpMutableVarsClassificationType.Value
153+
do self.DisplayName <- SR.FSharpMutableVarsClassificationType()
154154
self.ForegroundColor <- theme.GetColor FSharpClassificationTypes.MutableVar
155155

156156
[<Export(typeof<EditorFormatDefinition>)>]
@@ -161,7 +161,7 @@ module internal ClassificationDefinitions =
161161
type internal FSharpPrintfTypeFormat [<ImportingConstructor>](theme: ThemeColors) as self =
162162
inherit ClassificationFormatDefinition()
163163

164-
do self.DisplayName <- SR.FSharpPrintfFormatClassificationType.Value
164+
do self.DisplayName <- SR.FSharpPrintfFormatClassificationType()
165165
self.ForegroundColor <- theme.GetColor FSharpClassificationTypes.Printf
166166

167167
[<Export(typeof<EditorFormatDefinition>)>]
@@ -172,7 +172,7 @@ module internal ClassificationDefinitions =
172172
type internal FSharpPropertyFormat() as self =
173173
inherit ClassificationFormatDefinition()
174174

175-
do self.DisplayName <- SR.FSharpPropertiesClassificationType.Value
175+
do self.DisplayName <- SR.FSharpPropertiesClassificationType()
176176

177177
[<Export(typeof<EditorFormatDefinition>)>]
178178
[<ClassificationType(ClassificationTypeNames = FSharpClassificationTypes.Disposable)>]
@@ -182,5 +182,5 @@ module internal ClassificationDefinitions =
182182
type internal FSharpDisposableFormat [<ImportingConstructor>](theme: ThemeColors) as self =
183183
inherit ClassificationFormatDefinition()
184184

185-
do self.DisplayName <- SR.FSharpDisposablesClassificationType.Value
185+
do self.DisplayName <- SR.FSharpDisposablesClassificationType()
186186
self.ForegroundColor <- theme.GetColor FSharpClassificationTypes.Disposable

CodeFix/AddNewKeywordToDisposableConstructorInvocation.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type internal FSharpAddNewKeywordCodeFixProvider() =
1919

2020
override this.RegisterCodeFixesAsync context : Task =
2121
async {
22-
let title = SR.AddNewKeyword.Value
22+
let title = SR.AddNewKeyword()
2323
context.RegisterCodeFix(
2424
CodeAction.Create(
2525
title,

CodeFix/ImplementInterfaceCodeFixProvider.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ type internal FSharpImplementInterfaceCodeFixProvider
130130
title)
131131
context.RegisterCodeFix(codeAction, diagnostics)
132132

133-
registerCodeFix SR.ImplementInterface.Value true
134-
registerCodeFix SR.ImplementInterfaceWithoutTypeAnnotation.Value false
133+
registerCodeFix (SR.ImplementInterface()) true
134+
registerCodeFix (SR.ImplementInterfaceWithoutTypeAnnotation()) false
135135
else
136136
()
137137

CodeFix/MissingReferenceCodeFixProvider.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ type internal MissingReferenceCodeFixProvider() =
7171
| Some refProject ->
7272
let codefix =
7373
createCodeFix(
74-
String.Format(SR.AddProjectReference.Value, refProject.Name),
74+
String.Format(SR.AddProjectReference(), refProject.Name),
7575
context,
7676
AddProjectRef (ProjectReference refProject.Id)
7777
)
@@ -90,7 +90,7 @@ type internal MissingReferenceCodeFixProvider() =
9090
| Some metadataRef ->
9191
let codefix =
9292
createCodeFix(
93-
String.Format(SR.AddAssemblyReference.Value, assemblyName),
93+
String.Format(SR.AddAssemblyReference(), assemblyName),
9494
context,
9595
AddMetadataRef metadataRef
9696
)

CodeFix/RemoveUnusedOpens.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ type internal FSharpRemoveUnusedOpensCodeFixProvider
5252
override __.RegisterCodeFixesAsync context : Task =
5353
async {
5454
let diagnostics = context.Diagnostics |> Seq.filter (fun x -> fixableDiagnosticIds |> List.contains x.Id) |> Seq.toImmutableArray
55-
context.RegisterCodeFix(createCodeFix(SR.RemoveUnusedOpens.Value, context), diagnostics)
55+
context.RegisterCodeFix(createCodeFix(SR.RemoveUnusedOpens(), context), diagnostics)
5656
} |> RoslynHelpers.StartAsyncUnitAsTask(context.CancellationToken)
5757

5858
override __.GetFixAllProvider() = WellKnownFixAllProviders.BatchFixer

CodeFix/RenameUnusedValue.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ type internal FSharpRenameUnusedValueCodeFixProvider
6565

6666
match symbolUse.Symbol with
6767
| :? FSharpMemberOrFunctionOrValue as func ->
68-
createCodeFix(context, symbolName, SR.PrefixValueNameWithUnderscore.Value, TextChange(TextSpan(context.Span.Start, 0), "_"))
68+
createCodeFix(context, symbolName, SR.PrefixValueNameWithUnderscore(), TextChange(TextSpan(context.Span.Start, 0), "_"))
6969

7070
if func.IsMemberThisValue then
71-
createCodeFix(context, symbolName, SR.RenameValueToDoubleUnderscore.Value, TextChange(context.Span, "__"))
71+
createCodeFix(context, symbolName, SR.RenameValueToDoubleUnderscore(), TextChange(context.Span, "__"))
7272
elif not func.IsMember then
73-
createCodeFix(context, symbolName, SR.RenameValueToUnderscore.Value, TextChange(context.Span, "_"))
73+
createCodeFix(context, symbolName, SR.RenameValueToUnderscore(), TextChange(context.Span, "_"))
7474
| _ -> ()
7575
}
7676
|> Async.Ignore

CodeFix/SimplifyName.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ type internal FSharpSimplifyNameCodeFixProvider() =
2424
for diagnostic in context.Diagnostics |> Seq.filter (fun x -> x.Id = fixableDiagnosticId) do
2525
let title =
2626
match diagnostic.Properties.TryGetValue(SimplifyNameDiagnosticAnalyzer.LongIdentPropertyKey) with
27-
| true, longIdent -> sprintf "%s '%s'" SR.SimplifyName.Value longIdent
28-
| _ -> SR.SimplifyName.Value
27+
| true, longIdent -> sprintf "%s '%s'" (SR.SimplifyName()) longIdent
28+
| _ -> SR.SimplifyName()
2929

3030
let codefix = createTextChangeCodeFix(title, context, (fun () -> asyncMaybe.Return [| TextChange(context.Span, "") |]))
3131

Diagnostics/SimplifyNameDiagnosticAnalyzer.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ type internal SimplifyNameDiagnosticAnalyzer() =
3434
static let Descriptor =
3535
DiagnosticDescriptor(
3636
id = IDEDiagnosticIds.SimplifyNamesDiagnosticId,
37-
title = SR.SimplifyName.Value,
38-
messageFormat = SR.NameCanBeSimplified.Value,
37+
title = SR.SimplifyName(),
38+
messageFormat = SR.NameCanBeSimplified(),
3939
category = DiagnosticCategory.Style,
4040
defaultSeverity = DiagnosticSeverity.Hidden,
4141
isEnabledByDefault = true,

Diagnostics/UnusedDeclarationsAnalyzer.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ type internal UnusedDeclarationsAnalyzer() =
2424
let Descriptor =
2525
DiagnosticDescriptor(
2626
id = DescriptorId,
27-
title = SR.TheValueIsUnused.Value,
28-
messageFormat = SR.TheValueIsUnused.Value,
27+
title = SR.TheValueIsUnused(),
28+
messageFormat = SR.TheValueIsUnused(),
2929
category = DiagnosticCategory.Style,
3030
defaultSeverity = DiagnosticSeverity.Hidden,
3131
isEnabledByDefault = true,

Diagnostics/UnusedOpensDiagnosticAnalyzer.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ type internal UnusedOpensDiagnosticAnalyzer() =
150150
static let Descriptor =
151151
DiagnosticDescriptor(
152152
id = IDEDiagnosticIds.RemoveUnnecessaryImportsDiagnosticId,
153-
title = SR.RemoveUnusedOpens.Value,
154-
messageFormat = SR.UnusedOpens.Value,
153+
title = SR.RemoveUnusedOpens(),
154+
messageFormat = SR.UnusedOpens(),
155155
category = DiagnosticCategory.Style,
156156
defaultSeverity = DiagnosticSeverity.Hidden,
157157
isEnabledByDefault = true,

0 commit comments

Comments
 (0)