Skip to content

Commit dcd3d37

Browse files
Updating to Pure.DI 2.1.60
1 parent 28c8c98 commit dcd3d37

22 files changed

+76
-79
lines changed

CSharpInteractive.Tests/CSharpInteractive.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<ItemGroup>
1111
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
1212
<PackageReference Include="Moq" Version="4.20.72" />
13-
<PackageReference Include="Pure.DI" Version="2.1.59">
13+
<PackageReference Include="Pure.DI" Version="2.1.60">
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
</PackageReference>

CSharpInteractive.Tests/LineCodeSourceTests.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@ namespace CSharpInteractive.Tests;
33
public class LineCodeSourceTests
44
{
55
[Fact]
6-
public void Should()
6+
public void ShouldIntiLine()
77
{
88
// Given
9-
var source = CreateInstance();
109

1110
// When
12-
source.Line = "Abc";
11+
var source = CreateInstance("Abc");
1312

1413
// Then
1514
source.Name.ShouldBe("Abc");
1615
source.ToArray().ShouldBe(["Abc"]);
1716
}
1817

19-
private static LineCodeSource CreateInstance() =>
20-
new();
18+
private static LineCodeSource CreateInstance(string line) =>
19+
new(line);
2120
}

CSharpInteractive.Tests/LoadFileCodeSourceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ public void ShouldProvideLoadCommand()
2525
}
2626

2727
private LoadFileCodeSource CreateInstance(string fileName) =>
28-
new(_filePathResolver.Object, _workingDirectoryContext.Object) {Name = fileName};
28+
new(_filePathResolver.Object, _workingDirectoryContext.Object, fileName);
2929
}

CSharpInteractive/CSharpInteractive.Tool.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<ItemGroup>
3232
<!--<CompilerVisibleProperty Include="PureDIProfilePath" />-->
3333
<PackageReference Include="Microsoft.CodeAnalysis.Scripting" Version="4.12.0" />
34-
<PackageReference Include="Pure.DI" Version="2.1.59">
34+
<PackageReference Include="Pure.DI" Version="2.1.60">
3535
<PrivateAssets>all</PrivateAssets>
3636
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3737
</PackageReference>

CSharpInteractive/CSharpInteractive.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<ItemGroup>
2424
<PackageReference Include="Microsoft.CodeAnalysis.Scripting" Version="4.12.0" />
25-
<PackageReference Include="Pure.DI" Version="2.1.59">
25+
<PackageReference Include="Pure.DI" Version="2.1.60">
2626
<PrivateAssets>all</PrivateAssets>
2727
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2828
</PackageReference>

CSharpInteractive/Composition.cs

Lines changed: 27 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace CSharpInteractive;
1717
using Microsoft.CodeAnalysis.CSharp;
1818
using Microsoft.CodeAnalysis.Scripting;
1919
using Pure.DI;
20+
using static DateTime;
2021
using static Pure.DI.Lifetime;
2122
using static Pure.DI.Tag;
2223
using CommandLineParser = Core.CommandLineParser;
@@ -29,8 +30,8 @@ internal partial class Composition
2930
private static void Setup()
3031
{
3132
DI.Setup()
32-
.Hint(Hint.Resolve, "Off")
33-
.Root<Root>("Root")
33+
.Hint(Hint.Resolve, Name.Off)
34+
.Root<Root>(nameof(Root))
3435

3536
#if TOOL
3637
.DefaultLifetime(Transient)
@@ -40,12 +41,12 @@ private static void Setup()
4041
ctx.Inject<ISettings>(out var settings);
4142
if (settings.InteractionMode == InteractionMode.Interactive)
4243
{
43-
ctx.Inject<IScriptRunner>(InteractionMode.Interactive, out var scriptRunner);
44+
ctx.Inject<IScriptRunner>(InteractiveTag, out var scriptRunner);
4445
return scriptRunner;
4546
}
4647
else
4748
{
48-
ctx.Inject<IScriptRunner>(InteractionMode.NonInteractive, out var scriptRunner);
49+
ctx.Inject<IScriptRunner>(NonInteractiveTag, out var scriptRunner);
4950
return scriptRunner;
5051
}
5152
})
@@ -58,8 +59,8 @@ private static void Setup()
5859
.DefaultLifetime(Singleton)
5960
.Bind(Unique).To<ExitManager>()
6061
.Bind(Unique).To<Debugger>()
61-
.Bind(InteractionMode.Interactive).To<InteractiveRunner>()
62-
.Bind(InteractionMode.NonInteractive).To<ScriptRunner>()
62+
.Bind(InteractiveTag).To<InteractiveRunner>()
63+
.Bind(NonInteractiveTag).To<ScriptRunner>()
6364
.Bind().To<CommandSource>()
6465
.Bind().To<Setting<TTE>>()
6566
.Bind(Unique).Bind<IReferenceRegistry>().To<ReferencesScriptOptionsFactory>()
@@ -68,19 +69,19 @@ private static void Setup()
6869
.Bind().As(Transient).To(_ => RunningMode.Application)
6970
#endif
7071
.DefaultLifetime(Transient)
71-
.Bind().To(_ => DateTime.Now)
72+
.Bind().To(_ => Now)
7273
.Bind().To(_ => typeof(Composition).Assembly)
7374
.Bind().To(_ => new CSharpParseOptions().LanguageVersion)
74-
.Bind(RuntimePath).To(_ => Path.GetDirectoryName(typeof(object).Assembly.Location) ?? string.Empty)
75+
.Bind(RuntimePathTag).To(_ => Path.GetDirectoryName(typeof(object).Assembly.Location) ?? string.Empty)
7576
.Bind().To((CancellationTokenSource cancellationTokenSource) => cancellationTokenSource.Token)
76-
.Bind(TargetFrameworkMoniker).To((Assembly assembly) => assembly.GetCustomAttribute<System.Runtime.Versioning.TargetFrameworkAttribute>()?.FrameworkName ?? string.Empty)
77+
.Bind(TargetFrameworkMonikerTag).To((Assembly assembly) => assembly.GetCustomAttribute<System.Runtime.Versioning.TargetFrameworkAttribute>()?.FrameworkName ?? string.Empty)
7778
.Bind().To(_ => Process.GetCurrentProcess())
78-
.Bind(ModuleFile).To((Process process) => process.MainModule?.FileName ?? string.Empty)
79+
.Bind(ModuleFileTag).To((Process process) => process.MainModule?.FileName ?? string.Empty)
7980
.Bind().To<ScriptCommandFactory>()
8081
.Bind().To<ReliableBuildContext>()
8182
.Bind().To<ProcessMonitor>()
8283
.Bind().To<ProcessManager>()
83-
.Bind(Base).To<BuildContext>()
84+
.Bind(BaseTag).To<BuildContext>()
8485
.Bind().To(_ => MemoryPool<TT>.Shared)
8586
.Bind().To<SourceResolver>()
8687
.Bind().To<MetadataResolver>()
@@ -119,12 +120,12 @@ private static void Setup()
119120
.Bind().To<FileExplorer>()
120121
.Bind().To<Utf8Encoding>()
121122
.Bind().To<BuildOutputProcessor>()
122-
.Bind(Base).To<DefaultBuildMessagesProcessor>()
123-
.Bind(Custom).To<CustomMessagesProcessor>()
123+
.Bind(BaseTag).To<DefaultBuildMessagesProcessor>()
124+
.Bind(CustomTag).To<CustomMessagesProcessor>()
124125
.Bind().To<TeamCityContext>()
125126
.Bind().To<SummaryPresenter>()
126127
.Bind().To<ExitCodeParser>()
127-
.Bind(Base).To<ProcessRunner>()
128+
.Bind(BaseTag).To<ProcessRunner>()
128129
.Bind().To<ProcessResultHandler>()
129130
.Bind().To<TextReplacer>()
130131
.Bind().To<RuntimeExplorer>()
@@ -133,14 +134,14 @@ private static void Setup()
133134
.Bind().To<Root>()
134135
.Bind().To(_ => new CancellationTokenSource())
135136
.Bind().To<CISpecific<TT>>()
136-
.Bind(Base).To<ConsoleInOut>()
137-
.Bind(TeamCity).To<TeamCityInOut>()
138-
.Bind(Ansi).To<AnsiInOut>()
137+
.Bind(BaseTag).To<ConsoleInOut>()
138+
.Bind(TeamCityTag).To<TeamCityInOut>()
139+
.Bind(AnsiTag).To<AnsiInOut>()
139140
.Bind().To<Console>()
140141
.Bind().To((ICISpecific<IStdOut> stdOut) => stdOut.Instance)
141142
.Bind().To((ICISpecific<IStdErr> stdErr) => stdErr.Instance)
142-
.Bind(Base, Ansi).To<Log<TT>>()
143-
.Bind(TeamCity).To<TeamCityLog<TT>>()
143+
.Bind(BaseTag, AnsiTag).To<Log<TT>>()
144+
.Bind(TeamCityTag).To<TeamCityLog<TT>>()
144145
.Bind().To((ICISpecific<ILog<TT>> log) => log.Instance)
145146
.Bind().To<CISettings>()
146147
.Bind().To<ExitTracker>()
@@ -149,18 +150,8 @@ private static void Setup()
149150
.Bind().To<Settings>()
150151
.Bind().To<Info>()
151152
.Bind().To<ConsoleSource>()
152-
.Bind(LoadFileCode).To(ctx => new Func<string, ICodeSource>(name =>
153-
{
154-
ctx.Inject<LoadFileCodeSource>(out var loadFileCodeSource);
155-
loadFileCodeSource.Name = name;
156-
return loadFileCodeSource;
157-
}))
158-
.Bind(LineCode).To(ctx => new Func<string, ICodeSource>(line =>
159-
{
160-
ctx.Inject<LineCodeSource>(out var lineCodeSource);
161-
lineCodeSource.Line = line;
162-
return lineCodeSource;
163-
}))
153+
.Bind(LoadFileCodeTag).To<LoadFileCodeSource>()
154+
.Bind(LineCodeTag).To<LineCodeSource>()
164155
.Bind().To<Statistics>()
165156
.Bind().To<CommandsRunner>()
166157
.Bind().To<CodeSourceCommandFactory>()
@@ -202,8 +193,8 @@ private static void Setup()
202193
.Bind(Unique).To<SettingCommandRunner<VerbosityLevel>>()
203194
.Bind(Unique).To<AddNuGetReferenceCommandFactory>()
204195
.Bind(Unique).To<AddNuGetReferenceCommandRunner>()
205-
.Bind(Base, Ansi).To<Properties>()
206-
.Bind(TeamCity).To<TeamCityProperties>()
196+
.Bind(BaseTag, AnsiTag).To<Properties>()
197+
.Bind(TeamCityTag).To<TeamCityProperties>()
207198
.Bind().To((ICISpecific<IProperties> properties) => properties.Instance)
208199

209200
// Public services
@@ -215,8 +206,9 @@ private static void Setup()
215206
.Bind().To<ServiceMessageFormatter>()
216207
.Bind().To<FlowIdGenerator>()
217208
.Bind().To<TimestampUpdater>()
218-
.Bind().To((ITeamCityServiceMessages teamCityServiceMessages, IConsole console)
219-
=> new SafeTeamCityWriter(teamCityServiceMessages.CreateWriter(str => console.WriteToOut((null, str + "\n")))))
209+
.Bind(BaseTag).To((ITeamCityServiceMessages teamCityServiceMessages, IConsole console)
210+
=> teamCityServiceMessages.CreateWriter(str => console.WriteToOut((null, str + "\n"))))
211+
.Bind().To<SafeTeamCityWriter>()
220212
.Bind().To<ServiceMessageParser>();
221213
}
222214
}

CSharpInteractive/Core/BuildMessageLogWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ namespace CSharpInteractive.Core;
88

99
internal class BuildMessageLogWriter(
1010
ILog<BuildMessageLogWriter> log,
11-
[Tag(Base)] IStdOut stdOut,
12-
[Tag(Base)] IStdErr stdErr)
11+
[Tag(BaseTag)] IStdOut stdOut,
12+
[Tag(BaseTag)] IStdErr stdErr)
1313
: IBuildMessageLogWriter
1414
{
1515
public void Write(ProcessInfo processInfo, BuildMessage message)

CSharpInteractive/Core/BuildRunner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ internal class BuildRunner(
1818
Func<IBuildContext> buildContextFactory,
1919
IBuildOutputProcessor buildOutputProcessor,
2020
Func<IProcessMonitor> monitorFactory,
21-
[Tag(Base)] IBuildMessagesProcessor defaultBuildMessagesProcessor,
22-
[Tag(Custom)] IBuildMessagesProcessor customBuildMessagesProcessor,
21+
[Tag(BaseTag)] IBuildMessagesProcessor defaultBuildMessagesProcessor,
22+
[Tag(CustomTag)] IBuildMessagesProcessor customBuildMessagesProcessor,
2323
IProcessResultHandler processResultHandler,
2424
IStartInfoDescription startInfoDescription,
2525
ICommandLineStatisticsRegistry statisticsRegistry)

CSharpInteractive/Core/CISpecific.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ namespace CSharpInteractive.Core;
88

99
internal class CISpecific<T>(
1010
ICISettings settings,
11-
[Tag(Base)] Func<T> defaultFactory,
12-
[Tag(TeamCity)] Func<T> teamcityFactory,
13-
[Tag(Ansi)] Func<T> ansiFactory)
11+
[Tag(BaseTag)] Func<T> defaultFactory,
12+
[Tag(TeamCityTag)] Func<T> teamcityFactory,
13+
[Tag(AnsiTag)] Func<T> ansiFactory)
1414
: ICISpecific<T>
1515
{
1616
public T Instance => settings.CIType switch

CSharpInteractive/Core/DotnetEnvironment.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ namespace CSharpInteractive.Core;
99
using static Pure.DI.Tag;
1010

1111
internal class DotNetEnvironment(
12-
[Tag(TargetFrameworkMoniker)] string targetFrameworkMoniker,
13-
[Tag(ModuleFile)] string moduleFile,
12+
[Tag(TargetFrameworkMonikerTag)] string targetFrameworkMoniker,
13+
[Tag(ModuleFileTag)] string moduleFile,
1414
IEnvironment environment,
1515
IFileExplorer fileExplorer)
1616
: IDotNetEnvironment, ITraceSource

CSharpInteractive/Core/LineCodeSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ namespace CSharpInteractive.Core;
44

55
using System.Collections;
66

7-
internal class LineCodeSource : ICodeSource
7+
internal class LineCodeSource(string line) : ICodeSource
88
{
9-
public string Line { get; set; } = string.Empty;
9+
public string Line { get; set; } = line;
1010

1111
public IEnumerator<string?> GetEnumerator() => Enumerable.Repeat(Line, 1).GetEnumerator();
1212

CSharpInteractive/Core/LoadFileCodeSource.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@
33
namespace CSharpInteractive.Core;
44

55
using System.Collections;
6+
using Pure.DI;
67

7-
internal class LoadFileCodeSource(
8-
IFilePathResolver filePathResolver,
9-
IScriptContext scriptContext) : ICodeSource
8+
internal class LoadFileCodeSource : ICodeSource
109
{
11-
private string _fileName = "";
10+
private readonly IScriptContext _scriptContext;
1211

13-
public string Name
12+
public LoadFileCodeSource(IFilePathResolver filePathResolver,
13+
IScriptContext scriptContext,
14+
string name)
1415
{
15-
get => _fileName;
16-
set
16+
_scriptContext = scriptContext;
17+
if (!filePathResolver.TryResolve(name, out var fullFilePath))
1718
{
18-
if (!filePathResolver.TryResolve(value, out var fullFilePath))
19-
{
20-
fullFilePath = value;
21-
}
22-
23-
_fileName = fullFilePath;
19+
Name = name;
2420
}
21+
22+
Name = fullFilePath;
2523
}
2624

25+
public string Name { get; }
26+
2727
public bool Internal => false;
2828

2929
public IEnumerator<string> GetEnumerator()
3030
{
31-
var scope = scriptContext.CreateScope(this);
32-
return new LinesEnumerator(new List<string> {$"#load \"{_fileName}\""}, () => scope.Dispose());
31+
var scope = _scriptContext.CreateScope(this);
32+
return new LinesEnumerator(new List<string> {$"#load \"{Name}\""}, () => scope.Dispose());
3333
}
3434

3535
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();

CSharpInteractive/Core/ProcessInFlowRunner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace CSharpInteractive.Core;
99
using static Pure.DI.Tag;
1010

1111
internal class ProcessInFlowRunner(
12-
[Tag(Base)] IProcessRunner baseProcessRunner,
12+
[Tag(BaseTag)] IProcessRunner baseProcessRunner,
1313
ICISettings ciSettings,
1414
ITeamCityWriter teamCityWriter,
1515
IFlowContext flowContext)

CSharpInteractive/Core/ReliableBuildContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ internal class ReliableBuildContext(
1212
ICISettings ciSettings,
1313
IFileSystem fileSystem,
1414
IMessagesReader messagesReader,
15-
[Tag(Base)] IBuildContext baseBuildContext)
15+
[Tag(BaseTag)] IBuildContext baseBuildContext)
1616
: IBuildContext
1717
{
1818
private readonly Dictionary<string, Output> _sources = new();

CSharpInteractive/Core/RuntimeExplorer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace CSharpInteractive.Core;
66
using static Pure.DI.Tag;
77

88
internal class RuntimeExplorer(
9-
[Tag(RuntimePath)] string runtimePath,
9+
[Tag(RuntimePathTag)] string runtimePath,
1010
IFileSystem fileSystem) : IRuntimeExplorer
1111
{
1212
public bool TryFindRuntimeAssembly(string assemblyPath, [MaybeNullWhen(false)] out string runtimeAssemblyPath)

CSharpInteractive/Core/SafeTeamCityWriter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
using JetBrains.TeamCity.ServiceMessages;
44
using JetBrains.TeamCity.ServiceMessages.Write.Special;
5+
using Pure.DI;
6+
using static Pure.DI.Tag;
57

6-
internal class SafeTeamCityWriter(ITeamCityWriter writer): ITeamCityWriter
8+
internal class SafeTeamCityWriter([Tag(BaseTag)] ITeamCityWriter writer): ITeamCityWriter
79
{
810
private readonly object _lockObject = new();
911

CSharpInteractive/Core/ScriptContentReplacer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class ScriptContentReplacer(
1414
IFileSystem fileSystem,
1515
IUniqueNameGenerator uniqueNameGenerator,
1616
IEnvironment environment,
17-
[Tag(LineCode)] Func<string, ICodeSource> codeSourceFactory)
17+
[Tag(LineCodeTag)] Func<string, ICodeSource> codeSourceFactory)
1818
: IScriptContentReplacer
1919
{
2020
[SuppressMessage("Performance", "CA1806:Do not ignore method results")]

CSharpInteractive/Core/Settings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ internal class Settings(
1111
IEnvironment environment,
1212
ICommandLineParser commandLineParser,
1313
ICodeSource consoleCodeSource,
14-
[Tag(LoadFileCode)] Func<string, ICodeSource> fileCodeSourceFactory)
14+
[Tag(LoadFileCodeTag)] Func<string, ICodeSource> fileCodeSourceFactory)
1515
: ISettings, ISettingSetter<VerbosityLevel>
1616
{
1717
private readonly object _lockObject = new();

CSharpInteractive/Core/TeamCityProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace CSharpInteractive.Core;
1010
using static Pure.DI.Tag;
1111

1212
internal class TeamCityProperties(
13-
[Tag(Base)] IProperties properties,
13+
[Tag(BaseTag)] IProperties properties,
1414
// ReSharper disable once SuggestBaseTypeForParameterInConstructor
1515
ITeamCityWriter teamCityWriter) : IProperties
1616
{

TestBuild/TestBuild.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<Using Include="System.Threading.Tasks"/>
2323
<Using Include="Host" Static="True"/>
2424
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1"/>
25-
<PackageReference Include="Pure.DI" Version="2.1.59">
25+
<PackageReference Include="Pure.DI" Version="2.1.60">
2626
<PrivateAssets>all</PrivateAssets>
2727
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2828
</PackageReference>

build.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
dotnet run -f net8.0 --project Build -- -p integrationTests=true -p version=1.0.0-beta
1+
dotnet run -f net9.0 --project Build -- -p integrationTests=true -p version=1.0.0-beta

0 commit comments

Comments
 (0)