Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
aa145e7
fix #1542: точное позиционирование ошибки
Mr-Rm May 29, 2025
9217227
убрано НЕ из бинарных операторов
Mr-Rm May 29, 2025
65a8d40
уточнение места ошибки препроцессора
Mr-Rm May 29, 2025
5b79c11
опечатки
Mr-Rm May 29, 2025
461e1b8
убран переход к следующему токену и возможное NRE
Mr-Rm May 30, 2025
6d8e2cb
Некоторая адаптация под нет8 в части указания фреймворка
EvilBeaver Jun 17, 2025
6d0eb1a
Разрешено использование комментариев в строке с директивой Использовать
EvilBeaver Jun 17, 2025
ae53749
Разрешены комментарии после аннотаций модуля
EvilBeaver Jun 17, 2025
5ee6ad0
Ошибочно вкоммитил net8
EvilBeaver Jun 17, 2025
9d2ddf6
Initial plan for issue
Copilot Jun 19, 2025
ca6e382
Исправление ошибки в дженкинсфайле
EvilBeaver Jun 19, 2025
90d26e4
Merge remote-tracking branch 'origin/develop' into develop
EvilBeaver Jun 19, 2025
75adaad
Implement basic script caching infrastructure
Copilot Jun 19, 2025
ebdb5da
Complete script caching infrastructure with tests and documentation
Copilot Jun 19, 2025
d8dfe79
Правка замечания от кролика
EvilBeaver Jun 19, 2025
faa57af
Enhance cache integration with library loading and add documentation
Copilot Jun 19, 2025
e39dee9
Merge pull request #1553 from EvilBeaver/feature/1545-comment-after-d…
EvilBeaver Jun 19, 2025
4999c75
Просочились неявные юсинги
EvilBeaver Jun 19, 2025
6b63e42
Implement full script module serialization/deserialization for caching
Copilot Jun 19, 2025
11f4159
Migrate script serialization from BinaryFormatter to MessagePack
Copilot Jun 19, 2025
b78523a
Fix error handling, configuration, and logging in script caching
Copilot Jun 19, 2025
4eb499d
Enhance method serialization to support MachineMethodInfo structures
Copilot Jun 19, 2025
256893f
Remove redundant checks and implement IoC for cache service
Copilot Jun 19, 2025
cecf707
Address code review feedback: rename config, remove builders, add exc…
Copilot Jun 19, 2025
6b3bb3d
Существенно ускорена компиляция большого числа модулей
EvilBeaver Jun 19, 2025
6ebb094
изменена отметка позиции ошибки
Mr-Rm Jun 19, 2025
57f5cc5
Address final code review comments: remove fallback, fix redundant ch…
Copilot Jun 19, 2025
1a8f0b4
Однократное считывание файла исходника, при регистрации
EvilBeaver Jun 19, 2025
28a4a75
Привнес ошибку, вернул правильный код
EvilBeaver Jun 19, 2025
01885f3
Merge upstream develop branch to resolve conflicts
Copilot Jun 19, 2025
c89c18b
Fix failing ScriptCacheServiceTests by adding proper mock setup
Copilot Jun 19, 2025
72fb882
Temporarily disable script caching by default to fix Windows build
Copilot Jun 19, 2025
1078f1b
Fix boolean constant deserialization to handle localized values
Copilot Jun 19, 2025
be42206
Fix compilation errors in boolean and numeric constant deserialization
Copilot Jun 19, 2025
67bb1cb
Enable script caching by default in configuration
Copilot Jun 19, 2025
05c04c9
Fix build issues and CodeRabbit AI concerns - disable caching by defa…
Copilot Jun 19, 2025
712f238
Re-enable script caching by default as requested
Copilot Jun 19, 2025
1a6c1cf
Fix Windows path resolution issue in cached module loading
Copilot Jun 19, 2025
9724e39
Merge pull request #1547 from Mr-Rm/v2/fix-1542
EvilBeaver Jun 20, 2025
1bab56e
Debug script caching path resolution issue - discovered root cause no…
Copilot Jun 25, 2025
60c1c57
Add oscript_modules directory with package-loader.os for system libra…
Copilot Jun 25, 2025
59251a7
Add comprehensive debug logging for script caching operations
Copilot Jun 25, 2025
1c94e05
Fix library loading issue by diagnosing missing package-loader.os
Copilot Jun 25, 2025
00cf2d6
Fix BslScriptMethodInfo deserialization in caching - add protected co…
Copilot Jun 27, 2025
d0a3e8a
Create copilot-setup-steps.yml
nixel2007 Jun 27, 2025
c860dca
Update copilot-setup-steps.yml
nixel2007 Jun 27, 2025
ded0476
Update copilot-setup-steps.yml
nixel2007 Jun 27, 2025
ff9fe1e
Create copilot-instructions.md
nixel2007 Jun 27, 2025
56d4736
Add test result files for comprehensive build and test validation
Copilot Jun 27, 2025
2a98135
Update copilot-setup-steps.yml
nixel2007 Jun 27, 2025
9610c78
Update copilot-setup-steps.yml
nixel2007 Jun 27, 2025
e319faa
Update copilot-instructions.md
nixel2007 Jun 28, 2025
57ae651
Fix Build.csproj to exclude TestApp and NativeApi from Linux builds
Copilot Jun 28, 2025
5c02c58
Fix script cache deserialization index out of range issues
Copilot Jun 28, 2025
1b80a11
Remove manual cache service setup from AttachedScriptsFactory to fix …
Copilot Jun 28, 2025
a1ba5ce
Remove committed test result files and add them to .gitignore
Copilot Jun 28, 2025
6074475
Удалил кеши, добавленные копилотом
EvilBeaver Jul 9, 2025
f6a5ad6
Рефакторинг после копилота
EvilBeaver Jul 9, 2025
ced957e
Удалены файлы из LFS
EvilBeaver Jul 10, 2025
346ab70
Merge branch 'develop' of https://github.com/EvilBeaver/OneScript int…
EvilBeaver Jul 10, 2025
264a48d
Initial plan for issue
Copilot Jun 19, 2025
853aaa2
Implement basic script caching infrastructure
Copilot Jun 19, 2025
cf0eb06
Complete script caching infrastructure with tests and documentation
Copilot Jun 19, 2025
2d72695
Enhance cache integration with library loading and add documentation
Copilot Jun 19, 2025
cf0f1f9
Implement full script module serialization/deserialization for caching
Copilot Jun 19, 2025
137310b
Migrate script serialization from BinaryFormatter to MessagePack
Copilot Jun 19, 2025
9f9a71c
Fix error handling, configuration, and logging in script caching
Copilot Jun 19, 2025
c228753
Enhance method serialization to support MachineMethodInfo structures
Copilot Jun 19, 2025
b0143ed
Remove redundant checks and implement IoC for cache service
Copilot Jun 19, 2025
def85ee
Address code review feedback: rename config, remove builders, add exc…
Copilot Jun 19, 2025
08662b1
Address final code review comments: remove fallback, fix redundant ch…
Copilot Jun 19, 2025
0d37282
Fix failing ScriptCacheServiceTests by adding proper mock setup
Copilot Jun 19, 2025
140d3f7
Temporarily disable script caching by default to fix Windows build
Copilot Jun 19, 2025
697e552
Fix boolean constant deserialization to handle localized values
Copilot Jun 19, 2025
04c71bb
Fix compilation errors in boolean and numeric constant deserialization
Copilot Jun 19, 2025
d2edbac
Enable script caching by default in configuration
Copilot Jun 19, 2025
ba1fb84
Fix build issues and CodeRabbit AI concerns - disable caching by defa…
Copilot Jun 19, 2025
c1143cb
Re-enable script caching by default as requested
Copilot Jun 19, 2025
0e929f4
Fix Windows path resolution issue in cached module loading
Copilot Jun 19, 2025
80e4b7f
Debug script caching path resolution issue - discovered root cause no…
Copilot Jun 25, 2025
357727c
Add oscript_modules directory with package-loader.os for system libra…
Copilot Jun 25, 2025
cf88557
Add comprehensive debug logging for script caching operations
Copilot Jun 25, 2025
737d76d
Fix library loading issue by diagnosing missing package-loader.os
Copilot Jun 25, 2025
2b544df
Fix BslScriptMethodInfo deserialization in caching - add protected co…
Copilot Jun 27, 2025
71d0fbf
Create copilot-setup-steps.yml
nixel2007 Jun 27, 2025
55ae0a0
Update copilot-setup-steps.yml
nixel2007 Jun 27, 2025
a0ce373
Update copilot-setup-steps.yml
nixel2007 Jun 27, 2025
10c49a3
Create copilot-instructions.md
nixel2007 Jun 27, 2025
069e99b
Add test result files for comprehensive build and test validation
Copilot Jun 27, 2025
a62b8c6
Update copilot-setup-steps.yml
nixel2007 Jun 27, 2025
605f72f
Update copilot-setup-steps.yml
nixel2007 Jun 27, 2025
5cb1928
Update copilot-instructions.md
nixel2007 Jun 28, 2025
7ef5c59
Fix Build.csproj to exclude TestApp and NativeApi from Linux builds
Copilot Jun 28, 2025
60c53a7
Fix script cache deserialization index out of range issues
Copilot Jun 28, 2025
9979624
Remove manual cache service setup from AttachedScriptsFactory to fix …
Copilot Jun 28, 2025
d597567
Remove committed test result files and add them to .gitignore
Copilot Jun 28, 2025
94533c2
Удалил кеши, добавленные копилотом
EvilBeaver Jul 9, 2025
d607680
Рефакторинг после копилота
EvilBeaver Jul 9, 2025
d43a159
Merge remote-tracking branch 'nixel2007/copilot/fix-1' into copilot/f…
EvilBeaver Jul 10, 2025
ab67ad3
Установка глобальной библиотеки пакетов
nixel2007 Jul 10, 2025
7bb5d09
Update copilot-instructions.md
nixel2007 Jul 10, 2025
b9547ac
Add script cache files to .gitignore to prevent committing generated …
Copilot Jul 10, 2025
c437e04
Корректный вызов функции в MSBuild
EvilBeaver Jul 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Команда запуска полной сборки и прогона тестов на Linux:

```sh
dotnet msbuild Build.csproj /t:"CleanAll;MakeFDD;GatherLibrary;ComposeDistributionFolders;Test" /p:Configuration=LinuxDebug /p:NoCppCompiler=True
```

Запуск приемочных тестов:

```sh
dotnet oscript.dll tests/testrunner.os -runAll tests
```
37 changes: 37 additions & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "OneScript Development Environment Setup"

# Allow testing of the setup steps from your repository's "Actions" tab.
on: workflow_dispatch

jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest

# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# Clone the repository to install dependencies
contents: read

# Setup steps for OneScript development environment
steps:
- name: Checkout code
uses: actions/checkout@v4

- run: git config --global core.quotepath false

- uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'

- name: Установка OneScript
uses: otymko/setup-onescript@v1.5
with:
version: stable

- name: Установка зависимостей
run: |
opm install opm
opm update --all

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,15 @@ src/DebugServer/node_modules/
# Visual Studio OpenCover and Test result
src/OpenCover
TestResult.xml
TestResults/
tests/component/Component.dll
tests/tests.xml
tests/*.xml

src/oscript/Properties/launchSettings\.json

*.DotSettings

# Script caching system generated files
*.metadata.json
*.obj
85 changes: 36 additions & 49 deletions Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<ProjectFile>oscript.csproj</ProjectFile>
<Framework>net6.0</Framework>
</PublishProjects>
<PublishProjects Include="TestApp">
<PublishProjects Include="TestApp" Condition="!$([MSBuild]::Contains('$(Configuration)', 'Linux'))">
<ProjectFile>TestApp.csproj</ProjectFile>
<Framework>net6.0-windows</Framework>
</PublishProjects>
Expand All @@ -51,7 +51,7 @@

</Target>

<Target Name="MakeCPP">
<Target Name="MakeCPP" Condition="!$(Configuration.Contains('Linux'))">
<MSBuild Projects="src\ScriptEngine.NativeApi\ScriptEngine.NativeApi.vcxproj"
Properties="Configuration=$(Configuration);Platform=%(PlatformItem.MSBuildNameCpp)"/>

Expand All @@ -75,19 +75,19 @@
<CppBinPrefix>$(MSBuildProjectDirectory)/src/ScriptEngine.NativeApi/bin/$(Configuration)</CppBinPrefix>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="!$(Configuration.Contains('Linux'))">
<CppX86 Include="$(CppBinPrefix)/x86/*.dll"/>
<CppX64 Include="$(CppBinPrefix)/x64/*.dll"/>
</ItemGroup>

<Copy SourceFiles="@(CppX86)" DestinationFolder="$(ArtifactsRoot)/fdd-x86/bin" />
<Copy SourceFiles="@(CppX64)" DestinationFolder="$(ArtifactsRoot)/fdd-x64/bin" />
<Copy SourceFiles="@(CppX86)" DestinationFolder="$(ArtifactsRoot)/fdd-x86/bin" Condition="!$(Configuration.Contains('Linux'))" />
<Copy SourceFiles="@(CppX64)" DestinationFolder="$(ArtifactsRoot)/fdd-x64/bin" Condition="!$(Configuration.Contains('Linux'))" />

<ItemGroup>
<BatFilesFDD Include="$(MSBuildProjectDirectory)\install\opm.bat"/>
<BatFilesFDD Include="$(MSBuildProjectDirectory)\install\oscript.bat"/>
<ShFilesFDD Include="$(MSBuildProjectDirectory)\install\opm"/>
<ShFilesFDD Include="$(MSBuildProjectDirectory)\install\oscript"/>
<BatFilesFDD Include="$(MSBuildProjectDirectory)/install/opm.bat" Condition="!$(Configuration.Contains('Linux'))"/>
<BatFilesFDD Include="$(MSBuildProjectDirectory)/install/oscript.bat" Condition="!$(Configuration.Contains('Linux'))"/>
<ShFilesFDD Include="$(MSBuildProjectDirectory)/install/opm"/>
<ShFilesFDD Include="$(MSBuildProjectDirectory)/install/oscript"/>
</ItemGroup>

<Copy SourceFiles="@(BatFilesFDD);@(ShFilesFDD)" DestinationFolder="$(ArtifactsRoot)/fdd-x86/bin"/>
Expand All @@ -106,23 +106,23 @@
</ItemGroup>

<Exec Command="dotnet publish &quot;src/oscript/oscript.csproj&quot; -r %(RuntimeID.Identity) --self-contained -c $(Configuration) -o &quot;$(ArtifactsRoot)/%(RuntimeID.Identity)/bin&quot;" UseUtf8Encoding="Always"/>
<Exec Command="dotnet publish &quot;src/TestApp/TestApp.csproj&quot; -f net6.0-windows -c $(Configuration) -p:Platform=%(PlatformItem.MSBuildName) -p:UseAppHost=true -o &quot;$(ArtifactsRoot)/win-%(PlatformItem.Identity)/bin&quot;" UseUtf8Encoding="Always"/>
<Exec Command="dotnet publish &quot;src/TestApp/TestApp.csproj&quot; -f net6.0-windows -c $(Configuration) -p:Platform=%(PlatformItem.MSBuildName) -p:UseAppHost=true -o &quot;$(ArtifactsRoot)/win-%(PlatformItem.Identity)/bin&quot;" UseUtf8Encoding="Always" Condition="!$(Configuration.Contains('Linux'))"/>

<PropertyGroup>
<CppBinPrefix>$(MSBuildProjectDirectory)/src/ScriptEngine.NativeApi/bin/$(Configuration)</CppBinPrefix>
</PropertyGroup>

<ItemGroup>
<ItemGroup Condition="!$(Configuration.Contains('Linux'))">
<CppX86 Include="$(CppBinPrefix)/x86/*.dll"/>
<CppX64 Include="$(CppBinPrefix)/x64/*.dll"/>
</ItemGroup>

<Copy SourceFiles="@(CppX86)" DestinationFolder="$(ArtifactsRoot)/win-x86/bin" />
<Copy SourceFiles="@(CppX64)" DestinationFolder="$(ArtifactsRoot)/win-x64/bin" />
<Copy SourceFiles="@(CppX86)" DestinationFolder="$(ArtifactsRoot)/win-x86/bin" Condition="!$(Configuration.Contains('Linux'))" />
<Copy SourceFiles="@(CppX64)" DestinationFolder="$(ArtifactsRoot)/win-x64/bin" Condition="!$(Configuration.Contains('Linux'))" />

<ItemGroup>
<BatFilesSCD Include="$(MSBuildProjectDirectory)\install\opm.bat"/>
<ShFilesSCD Include="$(MSBuildProjectDirectory)\install\opm"/>
<BatFilesSCD Include="$(MSBuildProjectDirectory)/install/opm.bat" Condition="!$(Configuration.Contains('Linux'))"/>
<ShFilesSCD Include="$(MSBuildProjectDirectory)/install/opm"/>
</ItemGroup>

<Copy SourceFiles="@(BatFilesSCD)" DestinationFolder="$(ArtifactsRoot)/win-x86/bin"/>
Expand Down Expand Up @@ -169,43 +169,29 @@
<CallTarget Targets="CleanIntermediates"/>
</Target>

<!-- Используется для поиска первого собранного oscript.exe -->
<UsingTask
TaskName="GetFirstItem"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
<ParameterGroup>
<Items ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<FirstItem ParameterType="System.String" Output="true" Required="false" />
</ParameterGroup>
<Task>
<Reference Include="System.Xml"/>
<Using Namespace="System.Linq"/>
<Code Type="Fragment" Language="cs">FirstItem = Items.First().ItemSpec;</Code>
</Task>
</UsingTask>


<Target Name="GatherLibrary">
<MakeDir Directories="$(LibDir)" />

<ItemGroup>
<Executable Include="$(ArtifactsRoot)/*x64/bin/oscript.dll"/>
</ItemGroup>

<!-- упадет если ничего не нашлось, и это хорошо -->
<GetFirstItem Items="@(Executable)">
<Output TaskParameter="FirstItem" PropertyName="Runner"/>
</GetFirstItem>
<!-- Use a simple workaround for getting first item -->
<PropertyGroup>
<ExecutableItems>@(Executable)</ExecutableItems>
<Runner>$(ArtifactsRoot)/fdd-x64/bin/oscript.dll</Runner>
</PropertyGroup>

<Exec Command="dotnet &quot;$(Runner)&quot; &quot;$(MSBuildProjectDirectory)/install/unicode-zipper.os&quot; unpack &quot;$(MSBuildProjectDirectory)/install/opm.ospx&quot; &quot;$(LibDir)/tmp&quot;" UseUtf8Encoding="Always"/>
<Exec Command="dotnet &quot;$(Runner)&quot; &quot;$(MSBuildProjectDirectory)/install/unicode-zipper.os&quot; unpack &quot;$(LibDir)/tmp/content.zip&quot; &quot;$(LibDir)/opm&quot;" UseUtf8Encoding="Always"/>

<Copy SourceFiles="$(MSBuildProjectDirectory)\install\package-loader.os" DestinationFolder="$(LibDir)"/>
<Copy SourceFiles="$(MSBuildProjectDirectory)/install/package-loader.os" DestinationFolder="$(LibDir)"/>
<RemoveDir Directories="$(LibDir)/tmp"/>

<PropertyGroup>
<OpmEntryPoint>opm\src\cmd\opm.os</OpmEntryPoint>
<OpmLaunch>dotnet $(Runner) &quot;$(LibDir)\$(OpmEntryPoint)&quot;</OpmLaunch>
<OpmEntryPoint>opm/src/cmd/opm.os</OpmEntryPoint>
<OpmLaunch>dotnet $(Runner) &quot;$(LibDir)/$(OpmEntryPoint)&quot;</OpmLaunch>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -237,7 +223,7 @@
<LibraryFiles Include="$(LibDir)/**/*" Exclude="package-loader.os"/>
</ItemGroup>

<Copy SourceFiles="$(MSBuildProjectDirectory)\install\release-notes.md" DestinationFiles="$(ArtifactsRoot)/%(TargetDir.Identity)/release-notes.md" />
<Copy SourceFiles="$(MSBuildProjectDirectory)/install/release-notes.md" DestinationFiles="$(ArtifactsRoot)/%(TargetDir.Identity)/release-notes.md" />

<!--Заставить Copy копировать batching-ом в несколько директорий рекурсивно - не удалось :(-->
<Copy SourceFiles="@(LibraryFiles)" DestinationFolder="$(ArtifactsRoot)/fdd-x64/lib/%(RecursiveDir)" />
Expand Down Expand Up @@ -295,13 +281,14 @@

<Delete Files="@(RemoveXMLTestResult)" />

<GetFirstItem Items="@(Executable)">
<Output TaskParameter="FirstItem" PropertyName="Runner"/>
</GetFirstItem>
<!-- Use a simple workaround for getting first item -->
<PropertyGroup>
<Runner>$(ArtifactsRoot)/fdd-x64/bin/oscript.dll</Runner>
</PropertyGroup>

<Exec
WorkingDirectory="$(MSBuildProjectDirectory)\tests"
Command="dotnet &quot;$(Runner)&quot; &quot;$(MSBuildProjectDirectory)\tests\testrunner.os&quot; -runall . xddReportPath ."
WorkingDirectory="$(MSBuildProjectDirectory)/tests"
Command="dotnet &quot;$(Runner)&quot; &quot;$(MSBuildProjectDirectory)/tests/testrunner.os&quot; -runall . xddReportPath ."
IgnoreExitCode="true"
ContinueOnError="true"
UseUtf8Encoding="Always">
Expand Down Expand Up @@ -331,12 +318,12 @@
ItemName="BuildVariant"/>
</CreateItem>

<!-- упадет если ничего не нашлось, и это хорошо -->
<GetFirstItem Items="@(Executable)">
<Output TaskParameter="FirstItem" PropertyName="Runner"/>
</GetFirstItem>
<!-- Use a simple workaround for getting first item -->
<PropertyGroup>
<Runner>$(ArtifactsRoot)/fdd-x64/bin/oscript.dll</Runner>
</PropertyGroup>

<Exec Command="dotnet &quot;$(Runner)&quot; &quot;$(MSBuildProjectDirectory)\install\unicode-zipper.os&quot; pack &quot;$(ArtifactsRoot)/%(RuntimeID.Identity)/*&quot; &quot;$(ArtifactsRoot)/OneScript-$(ReleaseNumber)-%(RuntimeID.Identity).zip&quot;" UseUtf8Encoding="Always"/>
<Exec Command="dotnet &quot;$(Runner)&quot; &quot;$(MSBuildProjectDirectory)/install/unicode-zipper.os&quot; pack &quot;$(ArtifactsRoot)/%(RuntimeID.Identity)/*&quot; &quot;$(ArtifactsRoot)/OneScript-$(ReleaseNumber)-%(RuntimeID.Identity).zip&quot;" UseUtf8Encoding="Always"/>
<RemoveDir Directories="$(ArtifactsRoot)/%(RuntimeID.Identity)" />
<Delete Files="@(VsixSources)" />
</Target>
Expand Down
113 changes: 113 additions & 0 deletions CACHE_DEMO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Демонстрация кэширования скриптов для библиотек OneScript

## Обзор

Система кэширования скриптов интегрирована с загрузчиком библиотек OneScript и автоматически работает с методами `ДобавитьКласс` и `ДобавитьМодуль`.

## Как работает кэширование

1. **Автоматическая интеграция**: Когда `LibraryLoader` использует методы `ДобавитьКласс()` или `ДобавитьМодуль()`, вызывается цепочка:
- `LibraryLoader.CompileFile()`
- `AttachedScriptsFactory.CompileModuleFromSource()`
- `ScriptCacheService.TryLoadFromCache()` и `ScriptCacheService.SaveToCache()`

2. **Кэш-файлы**: Для каждого скрипта создаются:
- `script.os.metadata.json` - метаданные с информацией о времени изменения, размере файла, версии рантайма
- `script.os.obj` - объектный файл с информацией о модуле

3. **Валидация кэша**: Кэш автоматически становится недействительным при:
- Изменении исходного файла (время модификации или размер)
- Обновлении версии рантайма OneScript

## Тестирование кэширования

### Включение отладочного режима

```bash
export OS_CACHE_DEBUG=1
```

### Включение трассировки загрузки библиотек

```bash
export OS_LRE_TRACE=1
```

### Создание тестовых файлов

1. **Тестовый модуль** (`/tmp/test_module.os`):
```bsl
// Тестовый модуль для демонстрации кэширования
Функция ПолучитьВремя() Экспорт
Возврат ТекущаяДата();
КонецФункции
```

2. **Тестовый класс** (`/tmp/test_class.os`):
```bsl
// Тестовый класс для демонстрации кэширования
Перем Значение;

Процедура ПриСозданииОбъекта()
Значение = "Тест";
КонецПроцедуры

Функция ПолучитьЗначение() Экспорт
Возврат Значение;
КонецФункции
```

3. **Загрузчик библиотеки** (`/tmp/package-loader.os`):
```bsl
Функция ПриЗагрузкеБиблиотеки(ПутьКБиблиотеке, СтандартнаяОбработка, ОтменитьЗагрузку)

// Добавляем модуль - будет создан кэш
ДобавитьМодуль("/tmp/test_module.os", "ТестМодуль");

// Добавляем класс - будет создан кэш
ДобавитьКласс("/tmp/test_class.os", "ТестКласс");

СтандартнаяОбработка = Ложь;

КонецФункции
```

### Проверка создания кэша

После выполнения загрузки библиотеки должны появиться файлы:
- `/tmp/test_module.os.metadata.json`
- `/tmp/test_module.os.obj`
- `/tmp/test_class.os.metadata.json`
- `/tmp/test_class.os.obj`

### Пример метаданных кэша

```json
{
"FormatVersion": 1,
"SourceModifiedTime": "2025-06-19T09:30:15.123456+00:00",
"SourceSize": 145,
"SourcePath": "/tmp/test_module.os",
"CacheCreatedTime": "2025-06-19T09:30:16.789012+00:00",
"RuntimeVersion": "2.0.0.0"
}
```

## Статус реализации

✅ **Готово:**
- Интеграция кэша с `AttachedScriptsFactory`
- Автоматическое кэширование при использовании `ДобавитьКласс` и `ДобавитьМодуль`
- Валидация кэша по времени изменения файла, размеру и версии рантайма
- Создание метаданных и объектных файлов
- Конфигурируемое включение/отключение кэширования

⚠️ **В разработке:**
- Полная сериализация/десериализация `IExecutableModule`
- Загрузка скомпилированных модулей из кэша

## Результат

Система кэширования **уже работает** с методами загрузчика библиотек `ДобавитьКласс` и `ДобавитьМодуль`. Кэш-файлы создаются автоматически, валидация работает корректно.

Инфраструктура готова для будущей реализации полной загрузки модулей из кэша, что даст значительное ускорение загрузки больших библиотек типа oneunit.
Loading