Skip to content

Commit cfcceda

Browse files
committed
Replace Links
1 parent 0964f68 commit cfcceda

18 files changed

Lines changed: 226 additions & 139 deletions

System.IO.Abstractions.Analyzers/Analyzers/FileSystemTypeAnalyzers/DirectoryAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class DirectoryAnalyzer : BaseFileSystemNodeAnalyzer
3232
/// </summary>
3333
private const string Description = Title;
3434

35-
private const string Link = "http://bit.ly/2Oz9iSx";
35+
private const string Link = "https://github.com/TestableIO/System.IO.Abstractions.Analyzers/blob/develop/docs/" + DiagnosticId + ".MD";
3636

3737
/// <summary>
3838
/// Diagnostic rule

System.IO.Abstractions.Analyzers/Analyzers/FileSystemTypeAnalyzers/DirectoryInfoAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class DirectoryInfoAnalyzer : BaseFileSystemNodeAnalyzer
3232
/// </summary>
3333
private const string Description = Title;
3434

35-
private const string Link = "http://bit.ly/2OCAmQF";
35+
private const string Link = "https://github.com/TestableIO/System.IO.Abstractions.Analyzers/blob/develop/docs/" + DiagnosticId + ".MD";
3636

3737
/// <summary>
3838
/// Diagnostic rule

System.IO.Abstractions.Analyzers/Analyzers/FileSystemTypeAnalyzers/FileAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class FileAnalyzer : BaseFileSystemNodeAnalyzer
3232
/// </summary>
3333
private const string Description = Title;
3434

35-
private const string Link = "http://bit.ly/2ODMgdq";
35+
private const string Link = "https://github.com/TestableIO/System.IO.Abstractions.Analyzers/blob/develop/docs/" + DiagnosticId + ".MD";
3636

3737
/// <summary>
3838
/// Diagnostic rule

System.IO.Abstractions.Analyzers/Analyzers/FileSystemTypeAnalyzers/FileInfoAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class FileInfoAnalyzer : BaseFileSystemNodeAnalyzer
3232
/// </summary>
3333
private const string Description = Title;
3434

35-
private const string Link = "http://bit.ly/2OAA4tM";
35+
private const string Link = "https://github.com/TestableIO/System.IO.Abstractions.Analyzers/blob/develop/docs/" + DiagnosticId + ".MD";
3636

3737
/// <summary>
3838
/// Diagnostic rule

System.IO.Abstractions.Analyzers/Analyzers/FileSystemTypeAnalyzers/FileStreamAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class FileStreamAnalyzer : BaseFileSystemNodeAnalyzer
3232
/// </summary>
3333
private const string Description = Title;
3434

35-
private const string Link = "http://bit.ly/2Oz5MaM";
35+
private const string Link = "https://github.com/TestableIO/System.IO.Abstractions.Analyzers/blob/develop/docs/" + DiagnosticId + ".MD";
3636

3737
/// <summary>
3838
/// Diagnostic rule

System.IO.Abstractions.Analyzers/Analyzers/FileSystemTypeAnalyzers/PathAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class PathAnalyzer : BaseFileSystemNodeAnalyzer
3232
/// </summary>
3333
private const string Description = Title;
3434

35-
private const string Link = "https://github.com/TestableIO/System.IO.Abstractions.Analyzers/blob/develop/docs/IO0006.MD";
35+
private const string Link = "https://github.com/TestableIO/System.IO.Abstractions.Analyzers/blob/develop/docs/" + DiagnosticId + ".MD";
3636

3737
/// <summary>
3838
/// Diagnostic rule

System.IO.Abstractions.Analyzers/Analyzers/FileSystemTypeAnalyzers/StreamReaderAnalyzer.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ public class StreamReaderAnalyzer : BaseFileSystemNodeAnalyzer
1515
/// Diagnostic Identifier
1616
/// </summary>
1717
[UsedImplicitly]
18-
public const string DiagnosticId = "IO0011";
18+
public const string DiagnosticId = Constants.IO0011;
1919

2020
/// <summary>
2121
/// Diagnostic Title
2222
/// </summary>
23-
private const string Title = "Replace StreamReader string constructor overload with stream based overload"
24-
+ " using a stream from IFileSystem.FileStream for improved testability";
23+
private const string Title = "Replace StreamReader string constructor overload with stream based overload using a stream from IFileSystem.FileStream for improved testability";
2524

2625
/// <summary>
2726
/// Diagnostic Message Format
@@ -33,6 +32,8 @@ public class StreamReaderAnalyzer : BaseFileSystemNodeAnalyzer
3332
/// </summary>
3433
private const string Description = Title;
3534

35+
private const string Link = "https://github.com/TestableIO/System.IO.Abstractions.Analyzers/blob/develop/docs/" + DiagnosticId + ".MD";
36+
3637
/// <summary>
3738
/// Diagnostic rule
3839
/// </summary>
@@ -42,7 +43,8 @@ public class StreamReaderAnalyzer : BaseFileSystemNodeAnalyzer
4243
Category,
4344
DiagnosticSeverity.Warning,
4445
true,
45-
$"{Description}.");
46+
$"{Description}.",
47+
Link);
4648

4749
/// <inheritdoc />
4850
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => [Rule];

System.IO.Abstractions.Analyzers/Analyzers/FileSystemTypeAnalyzers/StreamWriterAnalyzer.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public class StreamWriterAnalyzer : BaseFileSystemNodeAnalyzer
1515
/// Diagnostic Identifier
1616
/// </summary>
1717
[UsedImplicitly]
18-
public const string DiagnosticId = "IO0010";
18+
public const string DiagnosticId = Constants.IO0010;
1919

2020
/// <summary>
2121
/// Diagnostic Title
@@ -33,6 +33,8 @@ public class StreamWriterAnalyzer : BaseFileSystemNodeAnalyzer
3333
/// </summary>
3434
private const string Description = Title;
3535

36+
private const string Link = "https://github.com/TestableIO/System.IO.Abstractions.Analyzers/blob/develop/docs/" + DiagnosticId + ".MD";
37+
3638
/// <summary>
3739
/// Diagnostic rule
3840
/// </summary>
@@ -42,7 +44,8 @@ public class StreamWriterAnalyzer : BaseFileSystemNodeAnalyzer
4244
Category,
4345
DiagnosticSeverity.Warning,
4446
true,
45-
$"{Description}.");
47+
$"{Description}.",
48+
Link);
4649

4750
/// <inheritdoc />
4851
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => [Rule];

System.IO.Abstractions.Analyzers/CodeActions/DirectoryInfoCodeAction.cs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,34 @@ namespace System.IO.Abstractions.Analyzers.CodeActions;
1313
/// <summary>
1414
/// Code action to replace a <see cref="DirectoryInfo"/> with a IFileSystem.DirectoryInfo.
1515
/// </summary>
16-
public class DirectoryInfoCodeAction : CodeAction
16+
public class DirectoryInfoCodeAction(
17+
string title,
18+
Document document,
19+
ObjectCreationExpressionSyntax creationExpressionSyntax,
20+
FieldDeclarationSyntax field)
21+
: CodeAction
1722
{
18-
private readonly ObjectCreationExpressionSyntax _creationExpressionSyntax;
19-
20-
private readonly Document _document;
21-
22-
private readonly FieldDeclarationSyntax _field;
23-
24-
public DirectoryInfoCodeAction(string title, Document document, ObjectCreationExpressionSyntax creationExpressionSyntax,
25-
FieldDeclarationSyntax field)
26-
{
27-
Title = title;
28-
_document = document;
29-
_creationExpressionSyntax = creationExpressionSyntax;
30-
_field = field;
31-
}
32-
3323
/// <inheritdoc />
34-
public override string Title { get; }
24+
public override string Title { get; } = title;
3525

3626
/// <inheritdoc />
3727
public override string EquivalenceKey => Title;
3828

3929
/// <inheritdoc />
4030
protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
4131
{
42-
var editor = await DocumentEditor.CreateAsync(_document, cancellationToken)
32+
var editor = await DocumentEditor.CreateAsync(document, cancellationToken)
4333
.ConfigureAwait(false);
4434

45-
if (_creationExpressionSyntax.ArgumentList is null)
35+
if (creationExpressionSyntax.ArgumentList is null)
4636
{
47-
return _document;
37+
return document;
4838
}
4939

50-
var arguments = _creationExpressionSyntax.ArgumentList.Arguments.Select(x => x.ToFullString());
40+
var arguments = creationExpressionSyntax.ArgumentList.Arguments.Select(x => x.ToFullString());
5141

52-
editor.ReplaceNode(_creationExpressionSyntax,
53-
SF.ParseExpression($"{_field.Declaration.Variables.ToFullString()}.DirectoryInfo.New({string.Join(",", arguments)})"));
42+
editor.ReplaceNode(creationExpressionSyntax,
43+
SF.ParseExpression($"{field.Declaration.Variables.ToFullString()}.DirectoryInfo.New({string.Join(",", arguments)})"));
5444

5545
return await Formatter.FormatAsync(editor.GetChangedDocument(), cancellationToken: cancellationToken)
5646
.ConfigureAwait(false);

System.IO.Abstractions.Analyzers/CodeActions/FileInfoCodeAction.cs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,34 @@ namespace System.IO.Abstractions.Analyzers.CodeActions;
1313
/// <summary>
1414
/// Code action to replace a <see cref="FileInfo"/> with a IFileSystem.FileInfo.
1515
/// </summary>
16-
public class FileInfoCodeAction : CodeAction
16+
public class FileInfoCodeAction(
17+
string title,
18+
Document document,
19+
ObjectCreationExpressionSyntax creationExpressionSyntax,
20+
FieldDeclarationSyntax field)
21+
: CodeAction
1722
{
18-
private readonly ObjectCreationExpressionSyntax _creationExpressionSyntax;
19-
20-
private readonly Document _document;
21-
22-
private readonly FieldDeclarationSyntax _field;
23-
24-
public FileInfoCodeAction(string title, Document document, ObjectCreationExpressionSyntax creationExpressionSyntax,
25-
FieldDeclarationSyntax field)
26-
{
27-
Title = title;
28-
_document = document;
29-
_creationExpressionSyntax = creationExpressionSyntax;
30-
_field = field;
31-
}
32-
3323
/// <inheritdoc />
34-
public override string Title { get; }
24+
public override string Title { get; } = title;
3525

3626
/// <inheritdoc />
3727
public override string EquivalenceKey => Title;
3828

3929
/// <inheritdoc />
4030
protected override async Task<Document> GetChangedDocumentAsync(CancellationToken cancellationToken)
4131
{
42-
var editor = await DocumentEditor.CreateAsync(_document, cancellationToken)
32+
var editor = await DocumentEditor.CreateAsync(document, cancellationToken)
4333
.ConfigureAwait(false);
4434

45-
if (_creationExpressionSyntax.ArgumentList is null)
35+
if (creationExpressionSyntax.ArgumentList is null)
4636
{
47-
return _document;
37+
return document;
4838
}
4939

50-
var arguments = _creationExpressionSyntax.ArgumentList.Arguments.Select(x => x.ToFullString());
40+
var arguments = creationExpressionSyntax.ArgumentList.Arguments.Select(x => x.ToFullString());
5141

52-
editor.ReplaceNode(_creationExpressionSyntax,
53-
SF.ParseExpression($"{_field.Declaration.Variables.ToFullString()}.FileInfo.New({string.Join(",", arguments)})"));
42+
editor.ReplaceNode(creationExpressionSyntax,
43+
SF.ParseExpression($"{field.Declaration.Variables.ToFullString()}.FileInfo.New({string.Join(",", arguments)})"));
5444

5545
return await Formatter.FormatAsync(editor.GetChangedDocument(), cancellationToken: cancellationToken)
5646
.ConfigureAwait(false);

0 commit comments

Comments
 (0)