Skip to content

Commit

Permalink
Add mef-exportable IFileSystemService
Browse files Browse the repository at this point in the history
  • Loading branch information
georgii-borovinskikh-sonarsource committed Nov 28, 2024
1 parent b850d05 commit 7b3e2eb
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Core.UnitTests/SystemAbstractions/FileSystemServiceTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* SonarLint for Visual Studio
* Copyright (C) 2016-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using SonarLint.VisualStudio.Core.SystemAbstractions;
using SonarLint.VisualStudio.TestInfrastructure;

namespace SonarLint.VisualStudio.Core.UnitTests.SystemAbstractions;

[TestClass]
public class FileSystemServiceTests
{
[TestMethod]
public void MefCtor_CheckIsExported() => MefTestHelpers.CheckTypeCanBeImported<FileSystemService, IFileSystemService>();

[TestMethod]
public void MefCtor_CheckIsSingleton() => MefTestHelpers.CheckIsSingletonMefComponent<FileSystemService>();
}
30 changes: 30 additions & 0 deletions src/Core/SystemAbstractions/IFileSystemService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* SonarLint for Visual Studio
* Copyright (C) 2016-2024 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

using System.ComponentModel.Composition;
using System.IO.Abstractions;

namespace SonarLint.VisualStudio.Core.SystemAbstractions;

public interface IFileSystemService : IFileSystem; // separate export interface to avoid conflicts

[Export(typeof(IFileSystemService))]
[PartCreationPolicy(CreationPolicy.Shared)]
public sealed class FileSystemService : FileSystem, IFileSystemService; // exporting class

0 comments on commit 7b3e2eb

Please sign in to comment.