├── src ├── NugetTests │ ├── fileAtRoot.txt │ ├── globFileAtRoot.txt │ ├── SpecificDirectory │ │ ├── File3.txt │ │ ├── Dir1 │ │ │ ├── File1.txt │ │ │ └── File2.txt │ │ └── Dir2 │ │ │ └── File4.txt │ ├── Config │ │ └── appsettings.json │ ├── lower-case │ │ └── lower-case.json │ ├── RecursiveDirectory │ │ ├── SomeFile.txt │ │ └── SubDir │ │ │ └── NestedFile.txt │ ├── SameNamedDescendants │ │ ├── SubDir1 │ │ │ ├── NestedFile.txt │ │ │ └── Descendant │ │ │ │ └── NestedFile.txt │ │ └── SubDir2 │ │ │ ├── NestedFile.txt │ │ │ └── Descendant │ │ │ └── NestedFile.txt │ ├── GlobalUsings.cs │ ├── ExtendPartialTests.cs │ └── ComsumeTests.cs ├── ConsumingTests │ ├── contentAtRoot.txt │ ├── fileAtRoot.txt │ ├── globFileAtRoot.txt │ ├── contentUpdateAtRoot.txt │ ├── fileIncludeAtRoot.txt │ ├── SpecificDirectory │ │ ├── File3.txt │ │ ├── Dir1 │ │ │ ├── File1.txt │ │ │ └── File2.txt │ │ └── Dir2 │ │ │ └── File4.txt │ ├── Config │ │ └── appsettings.json │ ├── lower-case │ │ └── lower-case.json │ ├── RecursiveDirectory │ │ ├── SomeFile.txt │ │ └── SubDir │ │ │ └── NestedFile.txt │ ├── SameNamedDescendants │ │ ├── SubDir1 │ │ │ ├── NestedFile.txt │ │ │ └── Descendant │ │ │ │ └── NestedFile.txt │ │ └── SubDir2 │ │ │ ├── NestedFile.txt │ │ │ └── Descendant │ │ │ └── NestedFile.txt │ └── GlobalUsings.cs ├── Tests │ ├── IdentifierTest.SingleDigit.verified.txt │ ├── IdentifierTest.ChineseCharacters.verified.txt │ ├── IdentifierTest.KeywordName.verified.txt │ ├── IdentifierTest.NormalName.verified.txt │ ├── IdentifierTest.SingleCharacter.verified.txt │ ├── KeywordDetectTests.KeywordFor.verified.txt │ ├── KeywordDetectTests.KeywordInt.verified.txt │ ├── IdentifierTest.MixedCaseKeyword.verified.txt │ ├── IdentifierTest.NameWithHyphens.verified.txt │ ├── IdentifierTest.NameWithSpaces.verified.txt │ ├── IdentifierTest.NameWithUnderscore.verified.txt │ ├── IdentifierTest.SingleSpecialCharacter.verified.txt │ ├── IdentifierTest.UnicodeCharacters.verified.txt │ ├── KeywordDetectTests.KeywordClass.verified.txt │ ├── KeywordDetectTests.KeywordPublic.verified.txt │ ├── KeywordDetectTests.KeywordString.verified.txt │ ├── KeywordDetectTests.KeywordWhile.verified.txt │ ├── IdentifierTest.AnotherKeywordName.verified.txt │ ├── IdentifierTest.NameStartingWithDigit.verified.txt │ ├── IdentifierTest.NameWithDots.verified.txt │ ├── IdentifierTest.NumbersInMiddle.verified.txt │ ├── KeywordDetectTests.EmptyString.verified.txt │ ├── KeywordDetectTests.KeywordNamespace.verified.txt │ ├── KeywordDetectTests.KeywordPrivate.verified.txt │ ├── KeywordDetectTests.NonKeywordNormal.verified.txt │ ├── KeywordDetectTests.KeywordWithDifferentCase.verified.txt │ ├── KeywordDetectTests.NonKeywordWithNumbers.verified.txt │ ├── IdentifierTest.NameWithMultipleUnderscores.verified.txt │ ├── IdentifierTest.NameWithSpecialCharacters.verified.txt │ ├── KeywordDetectTests.NonKeywordWithUnderscore.verified.txt │ ├── GeneratorTest.ImplicitUsingsEnabled#ProjectFiles.GlobalUsings.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsNoFiles#ProjectFiles.GlobalUsings.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsTrue#ProjectFiles.GlobalUsings.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsWithMsBuildProperties#ProjectFiles.GlobalUsings.g.verified.cs │ ├── TestExtensions.cs │ ├── ModuleInitializer.cs │ ├── MockAdditionalText.cs │ ├── GlobalUsings.cs │ ├── GeneratorTest.NoFiles#ProjectFiles.g.verified.cs │ ├── GeneratorTest.NoFilesWithMetadata#ProjectFiles.g.verified.cs │ ├── GeneratorTest.NoConflictWhenPropertyNotSet#ProjectFiles.g.verified.cs │ ├── GeneratorTest.OnlyProjectPropertyUndefined#ProjectFiles.g.verified.cs │ ├── GeneratorTest.PF0001_CSharp12Required.verified.txt │ ├── GeneratorTest.ImplicitUsingsFalse#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsNotSet#ProjectFiles.g.verified.cs │ ├── GeneratorTest.SingleFileAtRoot#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsEnabled#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ContentAtRoot#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsDisabled#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsTrue#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ContentWithAlwaysCopyToOutput#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ContentWithoutCopyToOutputDirectoryShouldBeIgnored#ProjectFiles.g.verified.cs │ ├── GeneratorTest.LinkedFileFromOtherProject#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsNoFiles#ProjectFiles.g.verified.cs │ ├── GeneratorTest.OnlyProjectProperty#ProjectFiles.g.verified.cs │ ├── GeneratorTest.OnlySolutionProperties#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ConflictWithSolutionDirectory#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ConflictWithSolutionFile#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ContentItemsGenerateCorrectPropertyNames#ProjectFiles.g.verified.cs │ ├── GeneratorTest.PartialMetadataMatch#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ConflictCaseInsensitive#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ConflictWithProjectFile#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ConflictWithProjectDirectory#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ContentInDirectory#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ProjectPropertyAndSolutionUndefined#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ContentWithVariousExtensions#ProjectFiles.g.verified.cs │ ├── GeneratorTest.MultipleFilesAtRoot#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ConflictWithProjectFile.verified.txt │ ├── GeneratorTest.ConflictWithSolutionFile.verified.txt │ ├── GeneratorTest.ConflictCaseInsensitive.verified.txt │ ├── GeneratorTest.PartialMsBuildProperties#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ConflictWithOtherValidFiles.verified.txt │ ├── GeneratorTest.ConflictWithProjectDirectory.verified.txt │ ├── GeneratorTest.NoConflictWhenPropertyNotSet.verified.txt │ ├── GeneratorTest.FilesWithSpecialCharacters#ProjectFiles.g.verified.cs │ ├── GeneratorTest.FilesInSingleDirectory#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ConflictWithSolutionDirectory.verified.txt │ ├── GeneratorTest.ContentWithUpdateAttribute#ProjectFiles.g.verified.cs │ ├── GeneratorTest.LinkedFileInSubdirectory#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ContentAndNoneInSameDirectory#ProjectFiles.g.verified.cs │ ├── GeneratorTest.NestedDirectoryConflictCaseInsensitive#ProjectFiles.g.verified.cs │ ├── GeneratorTest.MultipleConflicts#ProjectFiles.g.verified.cs │ ├── GeneratorTest.FilesWithKeywordNames#ProjectFiles.g.verified.cs │ ├── GeneratorTest.FileExtensionsInPropertyNames#ProjectFiles.g.verified.cs │ ├── GeneratorTest.MixedContentAndNoneItems#ProjectFiles.g.verified.cs │ ├── Tests.csproj │ ├── GeneratorTest.NoConflictInSubdirectory#ProjectFiles.g.verified.cs │ ├── GeneratorTest.AllMsBuildProperties#ProjectFiles.g.verified.cs │ ├── GeneratorTest.MixedFileAndDirectoryConflicts#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ContentInMultipleLevelsOfNesting#ProjectFiles.g.verified.cs │ ├── GeneratorTest.TriplyNestedSameDirectory#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ContentWithIncludeAttribute#ProjectFiles.g.verified.cs │ ├── GeneratorTest.MSBuildPropertiesWithUnixPaths#ProjectFiles.g.verified.cs │ ├── GeneratorTest.NestedDirectoryWithSameName#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ConflictWithOtherValidFiles#ProjectFiles.g.verified.cs │ ├── GeneratorTest.MixedRootAndDirectoryFiles#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ContentMixedIncludeAndUpdate#ProjectFiles.g.verified.cs │ ├── GeneratorTest.NoFiles#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentAtRoot#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentInDirectory#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsTrue#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.MultipleConflicts#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.NestedContentItems#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.SingleFileAtRoot#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.AllMsBuildProperties#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ConflictCaseInsensitive#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ConflictWithProjectFile#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.DeepNestedStructure#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.DeeplyNestedWithSameNameAtDifferentLevels#ProjectFiles.g.verified.cs │ ├── GeneratorTest.FilesInSingleDirectory#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.FilesWithKeywordNames#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsDisabled#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsEnabled#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsFalse#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsNoFiles#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsNotSet#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.MultipleFilesAtRoot#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.NoFilesWithMetadata#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.OnlyProjectProperty#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.OnlySolutionProperties#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.PartialMetadataMatch#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ConflictWithOtherValidFiles#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ConflictWithProjectDirectory#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ConflictWithSolutionFile#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentMixedIncludeAndUpdate#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentWithGlobbingPattern#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentWithIncludeAttribute#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentWithUpdateAttribute#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentWithVariousExtensions#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.FilesInNestedDirectories#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.FilesWithSpecialCharacters#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.LinkedFileFromOtherProject#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.LinkedFileInSubdirectory#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.MixedContentAndNoneItems#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.MixedRootAndDirectoryFiles#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.MsBuildPropertiesWithFiles#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.NestedDirectoryWithSameName#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.NoConflictInSubdirectory#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.NoConflictWhenPropertyNotSet#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.OnlyProjectPropertyUndefined#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.PartialMsBuildProperties#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.TriplyNestedSameDirectory#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ConflictWithSolutionDirectory#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentAndNoneInSameDirectory#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentInMultipleLevelsOfNesting#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentWithAlwaysCopyToOutput#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.FileExtensionsInPropertyNames#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.MSBuildPropertiesWithUnixPaths#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.MixedFileAndDirectoryConflicts#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsWithMsBuildProperties#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.MultipleContentItemsInNestedFolders#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.MultipleNestedDirectoriesWithSameName#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.NestedDirectoryConflictCaseInsensitive#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ProjectPropertyAndSolutionUndefined#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentItemsGenerateCorrectPropertyNames#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.DeeplyNestedWithSameNameAtDifferentLevels#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.ContentWithoutCopyToOutputDirectoryShouldBeIgnored#ProjectFiles.ProjectDirectory.g.verified.cs │ ├── GeneratorTest.MsBuildPropertiesWithFiles#ProjectFiles.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsWithMsBuildProperties#ProjectFiles.g.verified.cs │ ├── GeneratorTest.MultipleContentItemsInNestedFolders#ProjectFiles.g.verified.cs │ ├── GeneratorTest.DeepNestedStructure#ProjectFiles.g.verified.cs │ ├── GeneratorTest.FilesInNestedDirectories#ProjectFiles.g.verified.cs │ ├── MockOptionsProvider.cs │ ├── GeneratorTest.ContentWithGlobbingPattern#ProjectFiles.g.verified.cs │ ├── GeneratorTest.MultipleConflicts.verified.txt │ ├── GeneratorTest.MixedFileAndDirectoryConflicts.verified.txt │ ├── GeneratorTest.MultipleNestedDirectoriesWithSameName#ProjectFiles.g.verified.cs │ ├── GeneratorTest.NoFiles#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.ContentAtRoot#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.SingleFileAtRoot#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.AllMsBuildProperties#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.ContentInDirectory#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.DeepNestedStructure#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.FilesWithKeywordNames#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsEnabled#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsFalse#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsNoFiles#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsNotSet#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.ImplicitUsingsTrue#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.MultipleConflicts#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.MultipleFilesAtRoot#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.NestedContentItems#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.NoFilesWithMetadata#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.OnlyProjectProperty#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.PartialMetadataMatch#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.ConflictCaseInsensitive#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.ConflictWithProjectFile#ProjectFiles.ProjectFile.g.verified.cs │ ├── GeneratorTest.ConflictWithSolutionFile#ProjectFiles.ProjectFile.g.verified.cs │ └── GeneratorTest.ContentWithGlobbingPattern#ProjectFiles.ProjectFile.g.verified.cs ├── icon.png ├── key.snk ├── Templates │ ├── .editorconfig │ ├── Templates.csproj │ ├── ProjectDirectory.cs │ └── ProjectFile.cs ├── global.json ├── ProjectFiles │ ├── MsBuildProperties.cs │ ├── DirectoryNode.cs │ ├── GlobalUsings.cs │ ├── KeywordDetect.cs │ ├── Extensions.cs │ ├── Identifier.cs │ ├── SolutionDirectoryFinder.cs │ ├── ProjectFiles.csproj │ └── Diagnostics.cs ├── mdsnippets.json ├── ProjectFiles.slnx ├── Directory.Build.props ├── ProjectFiles.slnx.DotSettings ├── appveyor.yml ├── Directory.Packages.props └── nuget.config ├── IntegrationTests ├── IntegrationTests │ ├── contentAtRoot.txt │ ├── fileAtRoot.txt │ ├── globFileAtRoot.txt │ ├── contentUpdateAtRoot.txt │ ├── fileIncludeAtRoot.txt │ ├── SpecificDirectory │ │ ├── File3.txt │ │ ├── Dir1 │ │ │ ├── File1.txt │ │ │ └── File2.txt │ │ └── Dir2 │ │ │ └── File4.txt │ ├── Config │ │ └── appsettings.json │ ├── lower-case │ │ └── lower-case.json │ ├── RecursiveDirectory │ │ ├── SomeFile.txt │ │ └── SubDir │ │ │ └── NestedFile.txt │ ├── SameNamedDescendants │ │ ├── SubDir1 │ │ │ ├── NestedFile.txt │ │ │ └── Descendant │ │ │ │ └── NestedFile.txt │ │ └── SubDir2 │ │ │ ├── NestedFile.txt │ │ │ └── Descendant │ │ │ └── NestedFile.txt │ └── GlobalUsings.cs ├── IntegrationTests.slnx ├── global.json ├── Directory.Build.props └── Directory.Packages.props ├── .gitignore ├── .gitattributes └── license.txt /src/NugetTests/fileAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/contentAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/fileAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/globFileAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/NugetTests/globFileAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/contentUpdateAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/fileIncludeAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/NugetTests/SpecificDirectory/File3.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.SingleDigit.verified.txt: -------------------------------------------------------------------------------- 1 | _1 -------------------------------------------------------------------------------- /src/ConsumingTests/SpecificDirectory/File3.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/NugetTests/Config/appsettings.json: -------------------------------------------------------------------------------- 1 | {"key":"value"} 2 | -------------------------------------------------------------------------------- /src/NugetTests/SpecificDirectory/Dir1/File1.txt: -------------------------------------------------------------------------------- 1 | File 1 2 | -------------------------------------------------------------------------------- /src/NugetTests/SpecificDirectory/Dir1/File2.txt: -------------------------------------------------------------------------------- 1 | File 2 2 | -------------------------------------------------------------------------------- /src/NugetTests/SpecificDirectory/Dir2/File4.txt: -------------------------------------------------------------------------------- 1 | File 4 2 | -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.ChineseCharacters.verified.txt: -------------------------------------------------------------------------------- 1 | 文件 -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.KeywordName.verified.txt: -------------------------------------------------------------------------------- 1 | @class -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.NormalName.verified.txt: -------------------------------------------------------------------------------- 1 | MyFile -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.SingleCharacter.verified.txt: -------------------------------------------------------------------------------- 1 | a -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.KeywordFor.verified.txt: -------------------------------------------------------------------------------- 1 | @for -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.KeywordInt.verified.txt: -------------------------------------------------------------------------------- 1 | @int -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/contentAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/fileAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/globFileAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/Config/appsettings.json: -------------------------------------------------------------------------------- 1 | {"key":"value"} 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/SpecificDirectory/Dir1/File1.txt: -------------------------------------------------------------------------------- 1 | File 1 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/SpecificDirectory/Dir1/File2.txt: -------------------------------------------------------------------------------- 1 | File 2 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/SpecificDirectory/Dir2/File4.txt: -------------------------------------------------------------------------------- 1 | File 4 2 | -------------------------------------------------------------------------------- /src/NugetTests/lower-case/lower-case.json: -------------------------------------------------------------------------------- 1 | {"key":"value"} 2 | -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.MixedCaseKeyword.verified.txt: -------------------------------------------------------------------------------- 1 | Class -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.NameWithHyphens.verified.txt: -------------------------------------------------------------------------------- 1 | my_file -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.NameWithSpaces.verified.txt: -------------------------------------------------------------------------------- 1 | My_File -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.NameWithUnderscore.verified.txt: -------------------------------------------------------------------------------- 1 | _myfile -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.SingleSpecialCharacter.verified.txt: -------------------------------------------------------------------------------- 1 | _ -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.UnicodeCharacters.verified.txt: -------------------------------------------------------------------------------- 1 | café -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.KeywordClass.verified.txt: -------------------------------------------------------------------------------- 1 | @class -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.KeywordPublic.verified.txt: -------------------------------------------------------------------------------- 1 | @public -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.KeywordString.verified.txt: -------------------------------------------------------------------------------- 1 | @string -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.KeywordWhile.verified.txt: -------------------------------------------------------------------------------- 1 | @while -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/contentUpdateAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/fileIncludeAtRoot.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/lower-case/lower-case.json: -------------------------------------------------------------------------------- 1 | {"key":"value"} 2 | -------------------------------------------------------------------------------- /src/NugetTests/RecursiveDirectory/SomeFile.txt: -------------------------------------------------------------------------------- 1 | Some file content 2 | -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.AnotherKeywordName.verified.txt: -------------------------------------------------------------------------------- 1 | @namespace -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.NameStartingWithDigit.verified.txt: -------------------------------------------------------------------------------- 1 | _123file -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.NameWithDots.verified.txt: -------------------------------------------------------------------------------- 1 | my_config_json -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.NumbersInMiddle.verified.txt: -------------------------------------------------------------------------------- 1 | file123name -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.EmptyString.verified.txt: -------------------------------------------------------------------------------- 1 | emptyString -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.KeywordNamespace.verified.txt: -------------------------------------------------------------------------------- 1 | @namespace -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.KeywordPrivate.verified.txt: -------------------------------------------------------------------------------- 1 | @private -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.NonKeywordNormal.verified.txt: -------------------------------------------------------------------------------- 1 | MyClass -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/SpecificDirectory/File3.txt: -------------------------------------------------------------------------------- 1 | File 3 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/RecursiveDirectory/SomeFile.txt: -------------------------------------------------------------------------------- 1 | Some file content 2 | -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.KeywordWithDifferentCase.verified.txt: -------------------------------------------------------------------------------- 1 | Class -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.NonKeywordWithNumbers.verified.txt: -------------------------------------------------------------------------------- 1 | class123 -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/Config/appsettings.json: -------------------------------------------------------------------------------- 1 | {"key":"value"} 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/SpecificDirectory/Dir1/File1.txt: -------------------------------------------------------------------------------- 1 | File 1 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/SpecificDirectory/Dir1/File2.txt: -------------------------------------------------------------------------------- 1 | File 2 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/SpecificDirectory/Dir2/File4.txt: -------------------------------------------------------------------------------- 1 | File 4 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/RecursiveDirectory/SubDir/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /src/NugetTests/RecursiveDirectory/SubDir/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /src/NugetTests/SameNamedDescendants/SubDir1/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /src/NugetTests/SameNamedDescendants/SubDir2/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.NameWithMultipleUnderscores.verified.txt: -------------------------------------------------------------------------------- 1 | __my__file__ -------------------------------------------------------------------------------- /src/Tests/IdentifierTest.NameWithSpecialCharacters.verified.txt: -------------------------------------------------------------------------------- 1 | file____name -------------------------------------------------------------------------------- /src/Tests/KeywordDetectTests.NonKeywordWithUnderscore.verified.txt: -------------------------------------------------------------------------------- 1 | my_class -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/lower-case/lower-case.json: -------------------------------------------------------------------------------- 1 | {"key":"value"} 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/SameNamedDescendants/SubDir1/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/SameNamedDescendants/SubDir2/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /src/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonCropp/ProjectFiles/HEAD/src/icon.png -------------------------------------------------------------------------------- /src/key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonCropp/ProjectFiles/HEAD/src/key.snk -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/RecursiveDirectory/SomeFile.txt: -------------------------------------------------------------------------------- 1 | Some file content 2 | -------------------------------------------------------------------------------- /src/NugetTests/SameNamedDescendants/SubDir1/Descendant/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /src/NugetTests/SameNamedDescendants/SubDir2/Descendant/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/RecursiveDirectory/SubDir/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/SameNamedDescendants/SubDir1/Descendant/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /src/ConsumingTests/SameNamedDescendants/SubDir2/Descendant/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/SameNamedDescendants/SubDir1/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/SameNamedDescendants/SubDir2/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using System.IO; 2 | global using NUnit.Framework; -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/SameNamedDescendants/SubDir1/Descendant/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests/SameNamedDescendants/SubDir2/Descendant/NestedFile.txt: -------------------------------------------------------------------------------- 1 | Nested content 2 | -------------------------------------------------------------------------------- /src/Templates/.editorconfig: -------------------------------------------------------------------------------- 1 | root = false 2 | 3 | [*.cs] 4 | resharper_partial_type_with_single_part_highlighting = none -------------------------------------------------------------------------------- /src/ConsumingTests/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | // Global using directives 2 | 3 | global using System.IO; 4 | global using NUnit.Framework; -------------------------------------------------------------------------------- /IntegrationTests/IntegrationTests.slnx: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "10.0.101", 4 | "allowPrerelease": true, 5 | "rollForward": "latestFeature" 6 | } 7 | } -------------------------------------------------------------------------------- /src/ProjectFiles/MsBuildProperties.cs: -------------------------------------------------------------------------------- 1 | record MsBuildProperties( 2 | string? ProjectFile, 3 | string? SolutionFile, 4 | bool ImplicitUsings); -------------------------------------------------------------------------------- /IntegrationTests/global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "10.0.101", 4 | "allowPrerelease": true, 5 | "rollForward": "latestFeature" 6 | } 7 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.suo 2 | *.user 3 | bin/ 4 | obj/ 5 | .vs/ 6 | *.DotSettings.user 7 | .idea/ 8 | *.received.* 9 | nugets/ 10 | .claude/settings.local.json 11 | -------------------------------------------------------------------------------- /src/NugetTests/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | // Global using directives 2 | 3 | global using System.Collections.Generic; 4 | global using System.IO; 5 | global using NUnit.Framework; -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsEnabled#ProjectFiles.GlobalUsings.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.GlobalUsings.g.cs 2 | global using ProjectFilesGenerator; 3 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsNoFiles#ProjectFiles.GlobalUsings.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.GlobalUsings.g.cs 2 | global using ProjectFilesGenerator; 3 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsTrue#ProjectFiles.GlobalUsings.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.GlobalUsings.g.cs 2 | global using ProjectFilesGenerator; 3 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsWithMsBuildProperties#ProjectFiles.GlobalUsings.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.GlobalUsings.g.cs 2 | global using ProjectFilesGenerator; 3 | -------------------------------------------------------------------------------- /src/mdsnippets.json: -------------------------------------------------------------------------------- 1 | { 2 | "TocExcludes": [ "NuGet package", "Release Notes", "Icon" ], 3 | "MaxWidth": 100, 4 | "ValidateContent": true, 5 | "Convention": "InPlaceOverwrite" 6 | } -------------------------------------------------------------------------------- /IntegrationTests/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | preview 5 | 6 | -------------------------------------------------------------------------------- /src/Tests/TestExtensions.cs: -------------------------------------------------------------------------------- 1 | public static class TestExtensions 2 | { 3 | public static GeneratorDriver AddAdditionalTexts(this GeneratorDriver driver, IEnumerable additionalTexts) => 4 | driver.AddAdditionalTexts([..additionalTexts]); 5 | } -------------------------------------------------------------------------------- /src/Tests/ModuleInitializer.cs: -------------------------------------------------------------------------------- 1 | public static class ModuleInitializer 2 | { 3 | [ModuleInitializer] 4 | public static void Init() 5 | { 6 | VerifyDiffPlex.Initialize(OutputType.Compact); 7 | VerifierSettings.InitializePlugins(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/ProjectFiles/DirectoryNode.cs: -------------------------------------------------------------------------------- 1 | class DirectoryNode 2 | { 3 | public required string Path { get; init; } 4 | public required int Depth { get; init; } 5 | public Dictionary Directories { get; } = []; 6 | public List Files { get; } = []; 7 | } -------------------------------------------------------------------------------- /src/ProjectFiles/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using System.Collections.Immutable; 2 | global using System.Diagnostics.CodeAnalysis; 3 | global using System.Xml.Linq; 4 | global using Microsoft.CodeAnalysis; 5 | global using Microsoft.CodeAnalysis.CSharp; 6 | global using Microsoft.CodeAnalysis.Text; -------------------------------------------------------------------------------- /src/Tests/MockAdditionalText.cs: -------------------------------------------------------------------------------- 1 | class MockAdditionalText(string path, string text) : 2 | AdditionalText 3 | { 4 | public override string Path { get; } = path; 5 | 6 | public override SourceText GetText(Cancel cancel = default) => 7 | SourceText.From(text, Encoding.UTF8); 8 | } -------------------------------------------------------------------------------- /src/ProjectFiles/KeywordDetect.cs: -------------------------------------------------------------------------------- 1 | public static class KeywordDetect 2 | { 3 | public static string Sanitize(StringBuilder builder) 4 | { 5 | var result = builder.ToString(); 6 | if (SyntaxFacts.IsKeywordKind(SyntaxFacts.GetKeywordKind(result))) 7 | { 8 | return string.Concat("@", result); 9 | } 10 | 11 | return result; 12 | } 13 | } -------------------------------------------------------------------------------- /src/Tests/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using System.Runtime.CompilerServices; 2 | global using System.Text; 3 | global using Microsoft.CodeAnalysis; 4 | global using Microsoft.CodeAnalysis.CSharp; 5 | global using Microsoft.CodeAnalysis.Diagnostics; 6 | global using Microsoft.CodeAnalysis.Text; 7 | global using NUnit.Framework; 8 | global using ProjectFiles; 9 | global using VerifyTests; 10 | global using VerifyTests.DiffPlex; -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | *.snk binary 3 | *.png binary 4 | 5 | *.cs text eol=lf 6 | 7 | *.verified.txt text eol=lf working-tree-encoding=UTF-8 8 | *.verified.xml text eol=lf working-tree-encoding=UTF-8 9 | *.verified.json text eol=lf working-tree-encoding=UTF-8 10 | 11 | .editorconfig text eol=lf working-tree-encoding=UTF-8 12 | *.sln.DotSettings text eol=lf working-tree-encoding=UTF-8 13 | *.slnx.DotSettings text eol=lf working-tree-encoding=UTF-8 -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoFiles#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | } 13 | } 14 | 15 | namespace ProjectFilesGenerator.Types 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoFilesWithMetadata#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | } 13 | } 14 | 15 | namespace ProjectFilesGenerator.Types 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoConflictWhenPropertyNotSet#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | } 13 | } 14 | 15 | namespace ProjectFilesGenerator.Types 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.OnlyProjectPropertyUndefined#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | } 13 | } 14 | 15 | namespace ProjectFilesGenerator.Types 16 | { 17 | } 18 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.PF0001_CSharp12Required.verified.txt: -------------------------------------------------------------------------------- 1 | { 2 | Diagnostics: [ 3 | { 4 | Message: This generator requires C# 14 or later to run, 5 | Severity: Error, 6 | Descriptor: { 7 | Id: PROJFILES003, 8 | Title: C# 14 or later is required, 9 | MessageFormat: This generator requires C# 14 or later to run, 10 | Category: ProjectFiles, 11 | DefaultSeverity: Error, 12 | IsEnabledByDefault: true 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/Templates/Templates.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net461;net462;net47;net471;net472;net48;net481;net6.0-windows;netstandard2.0;netstandard2.1;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net10.0 5 | false 6 | NU1903;NU1902 7 | false 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsFalse#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile readme_md { get; } = new("readme.md"); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsNotSet#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile data_xml { get; } = new("data.xml"); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.SingleFileAtRoot#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile config_json { get; } = new("config.json"); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsEnabled#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile config_json { get; } = new("config.json"); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentAtRoot#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile contentAtRoot_txt { get; } = new("contentAtRoot.txt"); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsDisabled#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile config_json { get; } = new("config.json"); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsTrue#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile appsettings_json { get; } = new("appsettings.json"); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithAlwaysCopyToOutput#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile important_dat { get; } = new("important.dat"); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /IntegrationTests/Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithoutCopyToOutputDirectoryShouldBeIgnored#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile included_txt { get; } = new("included.txt"); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.LinkedFileFromOtherProject#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile file_in_other_project_txt { get; } = new("file in other project.txt"); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/ProjectFiles.slnx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/NugetTests/ExtendPartialTests.cs: -------------------------------------------------------------------------------- 1 | namespace ProjectFilesGenerator; 2 | 3 | abstract partial class ProjectDirectory 4 | { 5 | /// 6 | /// Recursively enumerates all files in this directory and subdirectories. 7 | /// 8 | public IEnumerable EnumerateFilesRecursively(string searchPattern = "*") => 9 | Directory.EnumerateFiles(Path, searchPattern, SearchOption.AllDirectories); 10 | 11 | /// 12 | /// Combines this directory path with additional path segments. 13 | /// 14 | public string Combine(params string[] paths) => 15 | System.IO.Path.Combine([Path, .. paths]); 16 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsNoFiles#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Dev/WebApi/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Dev/WebApi/foo.csproj"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.OnlyProjectProperty#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Dev/WebApi/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Dev/WebApi/WebApi.csproj"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.OnlySolutionProperties#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory SolutionDirectory { get; } = new("C:/Source/"); 13 | public static ProjectFile SolutionFile { get; } = new("C:/Source/MyProduct.sln"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithSolutionDirectory#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory SolutionDirectory { get; } = new("C:/Source/"); 13 | public static ProjectFile SolutionFile { get; } = new("C:/Source/MyProduct.sln"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithSolutionFile#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory SolutionDirectory { get; } = new("C:/Projects/"); 13 | public static ProjectFile SolutionFile { get; } = new("C:/Projects/MySolution.sln"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentItemsGenerateCorrectPropertyNames#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile app_settings_json { get; } = new("app.settings.json"); 13 | public static ProjectFile web_config { get; } = new("web.config"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.PartialMetadataMatch#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile also_has_metadata_txt { get; } = new("also-has-metadata.txt"); 13 | public static ProjectFile has_metadata_json { get; } = new("has-metadata.json"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictCaseInsensitive#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Projects/MyApp/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Projects/MyApp/foo.csproj"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithProjectFile#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Projects/MyApp/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Projects/MyApp/MyApp.csproj"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithProjectDirectory#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Projects/MyApp/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Projects/MyApp/MyApp.csproj"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentInDirectory#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static DataType Data { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class DataType() : ProjectDirectory("Data") 19 | { 20 | public ProjectFile config_json { get; } = new("Data/config.json"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ProjectPropertyAndSolutionUndefined#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Dev/WebApi/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Dev/WebApi/WebApi.csproj"); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithVariousExtensions#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile data_xml { get; } = new("data.xml"); 13 | public static ProjectFile readme_md { get; } = new("readme.md"); 14 | public static ProjectFile settings_yaml { get; } = new("settings.yaml"); 15 | } 16 | } 17 | 18 | namespace ProjectFilesGenerator.Types 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleFilesAtRoot#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile appsettings_json { get; } = new("appsettings.json"); 13 | public static ProjectFile license_txt { get; } = new("license.txt"); 14 | public static ProjectFile readme_md { get; } = new("readme.md"); 15 | } 16 | } 17 | 18 | namespace ProjectFilesGenerator.Types 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithProjectFile.verified.txt: -------------------------------------------------------------------------------- 1 | { 2 | Diagnostics: [ 3 | { 4 | Message: File 'ProjectFile.json' would generate property name 'ProjectFile' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 5 | Severity: Error, 6 | Descriptor: { 7 | Id: PROJFILES001, 8 | Title: File name conflicts with reserved property, 9 | MessageFormat: File '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 10 | Category: ProjectFiles, 11 | DefaultSeverity: Error, 12 | IsEnabledByDefault: true 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithSolutionFile.verified.txt: -------------------------------------------------------------------------------- 1 | { 2 | Diagnostics: [ 3 | { 4 | Message: File 'SolutionFile.xml' would generate property name 'SolutionFile' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 5 | Severity: Error, 6 | Descriptor: { 7 | Id: PROJFILES001, 8 | Title: File name conflicts with reserved property, 9 | MessageFormat: File '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 10 | Category: ProjectFiles, 11 | DefaultSeverity: Error, 12 | IsEnabledByDefault: true 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictCaseInsensitive.verified.txt: -------------------------------------------------------------------------------- 1 | { 2 | Diagnostics: [ 3 | { 4 | Message: File 'projectdirectory.txt' would generate property name 'projectdirectory' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 5 | Severity: Error, 6 | Descriptor: { 7 | Id: PROJFILES001, 8 | Title: File name conflicts with reserved property, 9 | MessageFormat: File '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 10 | Category: ProjectFiles, 11 | DefaultSeverity: Error, 12 | IsEnabledByDefault: true 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.PartialMsBuildProperties#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory SolutionDirectory { get; } = new("C:/Work/"); 13 | public static ProjectFile SolutionFile { get; } = new("C:/Work/Library.sln"); 14 | 15 | public static ProjectFile readme_md { get; } = new("readme.md"); 16 | } 17 | } 18 | 19 | namespace ProjectFilesGenerator.Types 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /src/ProjectFiles/Extensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis.Diagnostics; 2 | 3 | static class Extensions 4 | { 5 | public static IncrementalValuesProvider Select(this IncrementalValuesProvider source, Func selector) => 6 | source.Select((item, _) 7 | => selector(item)); 8 | 9 | public static string? GetValue(this AnalyzerConfigOptions options, string property) 10 | { 11 | if (!options.TryGetValue(property, out var value)) 12 | { 13 | return null; 14 | } 15 | 16 | if (string.IsNullOrWhiteSpace(value) || value == "*Undefined*") 17 | { 18 | return null; 19 | } 20 | 21 | return value; 22 | } 23 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithOtherValidFiles.verified.txt: -------------------------------------------------------------------------------- 1 | { 2 | Diagnostics: [ 3 | { 4 | Message: File 'ProjectDirectory.txt' would generate property name 'ProjectDirectory' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 5 | Severity: Error, 6 | Descriptor: { 7 | Id: PROJFILES001, 8 | Title: File name conflicts with reserved property, 9 | MessageFormat: File '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 10 | Category: ProjectFiles, 11 | DefaultSeverity: Error, 12 | IsEnabledByDefault: true 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithProjectDirectory.verified.txt: -------------------------------------------------------------------------------- 1 | { 2 | Diagnostics: [ 3 | { 4 | Message: File 'ProjectDirectory.txt' would generate property name 'ProjectDirectory' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 5 | Severity: Error, 6 | Descriptor: { 7 | Id: PROJFILES001, 8 | Title: File name conflicts with reserved property, 9 | MessageFormat: File '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 10 | Category: ProjectFiles, 11 | DefaultSeverity: Error, 12 | IsEnabledByDefault: true 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoConflictWhenPropertyNotSet.verified.txt: -------------------------------------------------------------------------------- 1 | { 2 | Diagnostics: [ 3 | { 4 | Message: File 'ProjectDirectory.json' would generate property name 'ProjectDirectory' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 5 | Severity: Error, 6 | Descriptor: { 7 | Id: PROJFILES001, 8 | Title: File name conflicts with reserved property, 9 | MessageFormat: File '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 10 | Category: ProjectFiles, 11 | DefaultSeverity: Error, 12 | IsEnabledByDefault: true 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | CS1591;NU1608;NU1109;RS2008;RS1041 5 | 0.4.0 6 | preview 7 | 1.0.0 8 | true 9 | true 10 | true 11 | true 12 | A C# source generator that provides strongly-typed, compile-time access to project files marked with CopyToOutputDirectory in the .csproj file. 13 | 14 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FilesWithSpecialCharacters#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile app_settings_dev_json { get; } = new("app.settings.dev.json"); 13 | public static ProjectFile file_with_underscore_txt { get; } = new("file_with_underscore.txt"); 14 | public static ProjectFile my_config_json { get; } = new("my-config.json"); 15 | } 16 | } 17 | 18 | namespace ProjectFilesGenerator.Types 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FilesInSingleDirectory#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ConfigType Config { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class ConfigType() : ProjectDirectory("Config") 19 | { 20 | public ProjectFile appsettings_json { get; } = new("Config/appsettings.json"); 21 | public ProjectFile database_json { get; } = new("Config/database.json"); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithSolutionDirectory.verified.txt: -------------------------------------------------------------------------------- 1 | { 2 | Diagnostics: [ 3 | { 4 | Message: Directory 'SolutionDirectory/config.json' would generate property name 'SolutionDirectory' that conflicts with reserved MSBuild property. Rename the directory or exclude its files from CopyToOutputDirectory., 5 | Severity: Error, 6 | Descriptor: { 7 | Id: PROJFILES002, 8 | Title: Directory name conflicts with reserved property, 9 | MessageFormat: Directory '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the directory or exclude its files from CopyToOutputDirectory., 10 | Category: ProjectFiles, 11 | DefaultSeverity: Error, 12 | IsEnabledByDefault: true 13 | } 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithUpdateAttribute#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile appsettings_Development_json { get; } = new("appsettings.Development.json"); 13 | public static ProjectFile appsettings_json { get; } = new("appsettings.json"); 14 | public static ProjectFile appsettings_Production_json { get; } = new("appsettings.Production.json"); 15 | } 16 | } 17 | 18 | namespace ProjectFilesGenerator.Types 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.LinkedFileInSubdirectory#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static AssetsType Assets { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class AssetsType() : ProjectDirectory("Assets") 19 | { 20 | public ImagesType Images { get; } = new(); 21 | public partial class ImagesType 22 | { 23 | public ProjectFile logo_png { get; } = new("Assets/Images/logo.png"); 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentAndNoneInSameDirectory#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ConfigType Config { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class ConfigType() : ProjectDirectory("Config") 19 | { 20 | public ProjectFile app_json { get; } = new("Config/app.json"); 21 | public ProjectFile database_xml { get; } = new("Config/database.xml"); 22 | public ProjectFile web_config { get; } = new("Config/web.config"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NestedDirectoryConflictCaseInsensitive#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static FolderType Folder { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class FolderType() : ProjectDirectory("Folder") 19 | { 20 | public folder_Level1Type folder { get; } = new(); 21 | public partial class folder_Level1Type 22 | { 23 | public ProjectFile file_txt { get; } = new("Folder/folder/file.txt"); 24 | } 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleConflicts#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Projects/MyApp/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Projects/MyApp/foo.csproj"); 14 | public static ProjectDirectory SolutionDirectory { get; } = new("C:/Projects/"); 15 | public static ProjectFile SolutionFile { get; } = new("C:/Projects/MySolution.sln"); 16 | } 17 | } 18 | 19 | namespace ProjectFilesGenerator.Types 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FilesWithKeywordNames#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile @class_json { get; } = new("class.json"); 13 | public static ProjectFile @namespace_txt { get; } = new("namespace.txt"); 14 | 15 | public static ConfigType Config { get; } = new(); 16 | } 17 | } 18 | 19 | namespace ProjectFilesGenerator.Types 20 | { 21 | partial class ConfigType() : ProjectDirectory("Config") 22 | { 23 | public ProjectFile @string_xml { get; } = new("Config/string.xml"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FileExtensionsInPropertyNames#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile config_json { get; } = new("config.json"); 13 | public static ProjectFile data_xml { get; } = new("data.xml"); 14 | public static ProjectFile file_txt { get; } = new("file.txt"); 15 | public static ProjectFile readme_md { get; } = new("readme.md"); 16 | public static ProjectFile script_ps1 { get; } = new("script.ps1"); 17 | } 18 | } 19 | 20 | namespace ProjectFilesGenerator.Types 21 | { 22 | } 23 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MixedContentAndNoneItems#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile appsettings_json { get; } = new("appsettings.json"); 13 | public static ProjectFile web_config { get; } = new("web.config"); 14 | 15 | public static TemplatesType Templates { get; } = new(); 16 | } 17 | } 18 | 19 | namespace ProjectFilesGenerator.Types 20 | { 21 | partial class TemplatesType() : ProjectDirectory("Templates") 22 | { 23 | public ProjectFile email_html { get; } = new("Templates/email.html"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Tests/Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net10.0 5 | true 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoConflictInSubdirectory#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Projects/MyApp/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Projects/MyApp/foo.csproj"); 14 | 15 | public static ConfigType Config { get; } = new(); 16 | } 17 | } 18 | 19 | namespace ProjectFilesGenerator.Types 20 | { 21 | partial class ConfigType() : ProjectDirectory("Config") 22 | { 23 | public ProjectFile ProjectDirectory_json { get; } = new("Config/ProjectDirectory.json"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/ProjectFiles.slnx.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | ..\Shared.sln.DotSettings 3 | True 4 | True 5 | 1 6 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.AllMsBuildProperties#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Projects/MyApp/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Projects/MyApp/MyApp.csproj"); 14 | public static ProjectDirectory SolutionDirectory { get; } = new("C:/Projects/"); 15 | public static ProjectFile SolutionFile { get; } = new("C:/Projects/MySolution.sln"); 16 | 17 | public static ProjectFile config_json { get; } = new("config.json"); 18 | } 19 | } 20 | 21 | namespace ProjectFilesGenerator.Types 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/ProjectFiles/Identifier.cs: -------------------------------------------------------------------------------- 1 | public static class Identifier 2 | { 3 | public static string Build(string name) 4 | { 5 | var builder = new StringBuilder(name.Length + 1); 6 | var first = name[0]; 7 | if (char.IsLetter(first) || first == '_') 8 | { 9 | builder.Append(first); 10 | } 11 | else 12 | { 13 | builder.Append('_'); 14 | if (char.IsDigit(first)) 15 | { 16 | builder.Append(first); 17 | } 18 | } 19 | 20 | for (var index = 1; index < name.Length; index++) 21 | { 22 | var ch = name[index]; 23 | if (char.IsLetterOrDigit(ch)) 24 | { 25 | builder.Append(ch); 26 | } 27 | else 28 | { 29 | builder.Append('_'); 30 | } 31 | } 32 | 33 | return KeywordDetect.Sanitize(builder); 34 | } 35 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MixedFileAndDirectoryConflicts#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Projects/MyApp/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Projects/MyApp/MyApp.csproj"); 14 | public static ProjectDirectory SolutionDirectory { get; } = new("C:/Source/"); 15 | public static ProjectFile SolutionFile { get; } = new("C:/Source/MyProduct.sln"); 16 | 17 | public static ProjectFile appsettings_json { get; } = new("appsettings.json"); 18 | } 19 | } 20 | 21 | namespace ProjectFilesGenerator.Types 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentInMultipleLevelsOfNesting#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static Level1Type Level1 { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class Level1Type() : ProjectDirectory("Level1") 19 | { 20 | public Level2Type Level2 { get; } = new(); 21 | public partial class Level2Type 22 | { 23 | public Level3Type Level3 { get; } = new(); 24 | public partial class Level3Type 25 | { 26 | public ProjectFile deep_txt { get; } = new("Level1/Level2/Level3/deep.txt"); 27 | } 28 | 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.TriplyNestedSameDirectory#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static TestType Test { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class TestType() : ProjectDirectory("Test") 19 | { 20 | public Test_Level1Type Test { get; } = new(); 21 | public partial class Test_Level1Type 22 | { 23 | public Test_Level2Type Test { get; } = new(); 24 | public partial class Test_Level2Type 25 | { 26 | public ProjectFile data_json { get; } = new("Test/Test/Test/data.json"); 27 | } 28 | 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2022 2 | environment: 3 | DOTNET_NOLOGO: true 4 | DOTNET_CLI_TELEMETRY_OPTOUT: true 5 | DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true 6 | build_script: 7 | - pwsh: | 8 | Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./dotnet-install.ps1" 9 | ./dotnet-install.ps1 -JSonFile src/global.json -Architecture x64 -InstallDir 'C:\Program Files\dotnet' 10 | - dotnet build src --configuration Release 11 | - dotnet test src --configuration Release --no-build --no-restore 12 | - dotnet build IntegrationTests --configuration Release 13 | - dotnet test IntegrationTests --configuration Release --no-build --no-restore 14 | # Test project-level build without $(SolutionDir) 15 | - dotnet build src/ConsumingTests/ConsumingTests.csproj --configuration Release --force 16 | - dotnet test src/ConsumingTests/ConsumingTests.csproj --configuration Release --no-build --no-restore 17 | 18 | test: off 19 | artifacts: 20 | - path: nugets\*.nupkg -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithIncludeAttribute#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile content_txt { get; } = new("content.txt"); 13 | 14 | public static DataType Data { get; } = new(); 15 | public static TemplatesType Templates { get; } = new(); 16 | } 17 | } 18 | 19 | namespace ProjectFilesGenerator.Types 20 | { 21 | partial class DataType() : ProjectDirectory("Data") 22 | { 23 | public ProjectFile seed_sql { get; } = new("Data/seed.sql"); 24 | } 25 | partial class TemplatesType() : ProjectDirectory("Templates") 26 | { 27 | public ProjectFile email_html { get; } = new("Templates/email.html"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MSBuildPropertiesWithUnixPaths#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/home/user/projects/myapp/"); 13 | public static ProjectFile ProjectFile { get; } = new("/home/user/projects/myapp/myapp.csproj"); 14 | public static ProjectDirectory SolutionDirectory { get; } = new("C:/home/user/projects/"); 15 | public static ProjectFile SolutionFile { get; } = new("/home/user/projects/mysolution.sln"); 16 | 17 | public static ProjectFile config_json { get; } = new("config.json"); 18 | } 19 | } 20 | 21 | namespace ProjectFilesGenerator.Types 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NestedDirectoryWithSameName#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static DirectoryType Directory { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class DirectoryType() : ProjectDirectory("Directory") 19 | { 20 | public NestedType Nested { get; } = new(); 21 | public partial class NestedType 22 | { 23 | public Nested_Level2Type Nested { get; } = new(); 24 | public partial class Nested_Level2Type 25 | { 26 | public ProjectFile file_txt { get; } = new("Directory/Nested/Nested/file.txt"); 27 | } 28 | 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithOtherValidFiles#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Projects/MyApp/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Projects/MyApp/foo.csproj"); 14 | 15 | public static ProjectFile appsettings_json { get; } = new("appsettings.json"); 16 | 17 | public static ConfigType Config { get; } = new(); 18 | } 19 | } 20 | 21 | namespace ProjectFilesGenerator.Types 22 | { 23 | partial class ConfigType() : ProjectDirectory("Config") 24 | { 25 | public ProjectFile database_json { get; } = new("Config/database.json"); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MixedRootAndDirectoryFiles#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile readme_md { get; } = new("readme.md"); 13 | 14 | public static ConfigType Config { get; } = new(); 15 | public static ScriptsType Scripts { get; } = new(); 16 | } 17 | } 18 | 19 | namespace ProjectFilesGenerator.Types 20 | { 21 | partial class ConfigType() : ProjectDirectory("Config") 22 | { 23 | public ProjectFile appsettings_json { get; } = new("Config/appsettings.json"); 24 | } 25 | partial class ScriptsType() : ProjectDirectory("Scripts") 26 | { 27 | public ProjectFile deploy_ps1 { get; } = new("Scripts/deploy.ps1"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Templates/ProjectDirectory.cs: -------------------------------------------------------------------------------- 1 | namespace ProjectFilesGenerator; 2 | 3 | using System.IO; 4 | using System.Collections.Generic; 5 | 6 | partial class ProjectDirectory(string path) 7 | { 8 | public string Path { get; } = path; 9 | 10 | public string FullPath => System.IO.Path.GetFullPath(Path); 11 | 12 | public override string ToString() => Path; 13 | 14 | public static implicit operator string(ProjectDirectory temp) => 15 | temp.Path; 16 | 17 | public static implicit operator FileInfo(ProjectDirectory temp) => 18 | new(temp.Path); 19 | 20 | public IEnumerable EnumerateDirectories() => 21 | Directory.EnumerateDirectories(Path); 22 | 23 | public IEnumerable EnumerateFiles() => 24 | Directory.EnumerateFiles(Path); 25 | 26 | public IEnumerable GetFiles() => 27 | Directory.GetFiles(Path); 28 | 29 | public IEnumerable GetDirectories() => 30 | Directory.GetDirectories(Path); 31 | 32 | public DirectoryInfo Info => new(Path); 33 | } -------------------------------------------------------------------------------- /src/ProjectFiles/SolutionDirectoryFinder.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable RS1035 2 | 3 | public static class SolutionDirectoryFinder 4 | { 5 | public static string? Find(string projectFile) 6 | { 7 | if (!File.Exists(projectFile)) 8 | { 9 | return null; 10 | } 11 | 12 | var directory = Directory.GetParent(projectFile); 13 | 14 | while (directory != null) 15 | { 16 | var path = directory.FullName; 17 | 18 | if (Directory.Exists(Path.Combine(path, ".git"))) 19 | { 20 | break; 21 | } 22 | 23 | var solution = Directory.EnumerateFiles(path, "*.sln*") 24 | .OrderByDescending(_ => _.Length) 25 | .FirstOrDefault(_ => _.EndsWith(".slnx") || _.EndsWith(".sln")); 26 | 27 | if (solution != null) 28 | { 29 | return solution; 30 | } 31 | 32 | directory = directory.Parent; 33 | } 34 | 35 | return null; 36 | } 37 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentMixedIncludeAndUpdate#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectFile appsettings_Development_json { get; } = new("appsettings.Development.json"); 13 | public static ProjectFile appsettings_json { get; } = new("appsettings.json"); 14 | 15 | public static DataType Data { get; } = new(); 16 | public static TemplatesType Templates { get; } = new(); 17 | } 18 | } 19 | 20 | namespace ProjectFilesGenerator.Types 21 | { 22 | partial class DataType() : ProjectDirectory("Data") 23 | { 24 | public ProjectFile seed_sql { get; } = new("Data/seed.sql"); 25 | } 26 | partial class TemplatesType() : ProjectDirectory("Templates") 27 | { 28 | public ProjectFile email_html { get; } = new("Templates/email.html"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoFiles#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentAtRoot#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentInDirectory#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsTrue#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleConflicts#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NestedContentItems#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.SingleFileAtRoot#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Simon Cropp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.AllMsBuildProperties#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictCaseInsensitive#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithProjectFile#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.DeepNestedStructure#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.DeeplyNestedWithSameNameAtDifferentLevels#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static RootType Root { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class RootType() : ProjectDirectory("Root") 19 | { 20 | public Level1Type Level1 { get; } = new(); 21 | public partial class Level1Type 22 | { 23 | public Level1_Level2Type Level1 { get; } = new(); 24 | public partial class Level1_Level2Type 25 | { 26 | public Level2Type Level2 { get; } = new(); 27 | public partial class Level2Type 28 | { 29 | public ProjectFile file_txt { get; } = new("Root/Level1/Level1/Level2/file.txt"); 30 | } 31 | 32 | } 33 | 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FilesInSingleDirectory#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FilesWithKeywordNames#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsDisabled#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsEnabled#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsFalse#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsNoFiles#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsNotSet#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleFilesAtRoot#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoFilesWithMetadata#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.OnlyProjectProperty#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.OnlySolutionProperties#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.PartialMetadataMatch#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithOtherValidFiles#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithProjectDirectory#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithSolutionFile#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentMixedIncludeAndUpdate#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithGlobbingPattern#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithIncludeAttribute#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithUpdateAttribute#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithVariousExtensions#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FilesInNestedDirectories#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FilesWithSpecialCharacters#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.LinkedFileFromOtherProject#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.LinkedFileInSubdirectory#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MixedContentAndNoneItems#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MixedRootAndDirectoryFiles#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MsBuildPropertiesWithFiles#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NestedDirectoryWithSameName#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoConflictInSubdirectory#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoConflictWhenPropertyNotSet#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.OnlyProjectPropertyUndefined#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.PartialMsBuildProperties#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.TriplyNestedSameDirectory#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithSolutionDirectory#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentAndNoneInSameDirectory#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentInMultipleLevelsOfNesting#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithAlwaysCopyToOutput#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FileExtensionsInPropertyNames#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MSBuildPropertiesWithUnixPaths#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MixedFileAndDirectoryConflicts#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsWithMsBuildProperties#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleContentItemsInNestedFolders#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleNestedDirectoriesWithSameName#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NestedDirectoryConflictCaseInsensitive#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ProjectPropertyAndSolutionUndefined#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentItemsGenerateCorrectPropertyNames#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.DeeplyNestedWithSameNameAtDifferentLevels#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Directory.Packages.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithoutCopyToOutputDirectoryShouldBeIgnored#ProjectFiles.ProjectDirectory.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectDirectory.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Collections.Generic; 6 | 7 | partial class ProjectDirectory(string path) 8 | { 9 | public string Path { get; } = path; 10 | 11 | public string FullPath => System.IO.Path.GetFullPath(Path); 12 | 13 | public override string ToString() => Path; 14 | 15 | public static implicit operator string(ProjectDirectory temp) => 16 | temp.Path; 17 | 18 | public static implicit operator FileInfo(ProjectDirectory temp) => 19 | new(temp.Path); 20 | 21 | public IEnumerable EnumerateDirectories() => 22 | Directory.EnumerateDirectories(Path); 23 | 24 | public IEnumerable EnumerateFiles() => 25 | Directory.EnumerateFiles(Path); 26 | 27 | public IEnumerable GetFiles() => 28 | Directory.GetFiles(Path); 29 | 30 | public IEnumerable GetDirectories() => 31 | Directory.GetDirectories(Path); 32 | 33 | public DirectoryInfo Info => new(Path); 34 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MsBuildPropertiesWithFiles#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Projects/MyApp/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Projects/MyApp/MyApp.csproj"); 14 | public static ProjectDirectory SolutionDirectory { get; } = new("C:/Projects/"); 15 | public static ProjectFile SolutionFile { get; } = new("C:/Projects/MySolution.sln"); 16 | 17 | public static ProjectFile appsettings_json { get; } = new("appsettings.json"); 18 | 19 | public static ConfigType Config { get; } = new(); 20 | } 21 | } 22 | 23 | namespace ProjectFilesGenerator.Types 24 | { 25 | partial class ConfigType() : ProjectDirectory("Config") 26 | { 27 | public ProjectFile database_json { get; } = new("Config/database.json"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsWithMsBuildProperties#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ProjectDirectory ProjectDirectory { get; } = new("C:/Projects/MyApp/"); 13 | public static ProjectFile ProjectFile { get; } = new("C:/Projects/MyApp/MyApp.csproj"); 14 | public static ProjectDirectory SolutionDirectory { get; } = new("C:/Projects/"); 15 | public static ProjectFile SolutionFile { get; } = new("C:/Projects/MySolution.sln"); 16 | 17 | public static ProjectFile appsettings_json { get; } = new("appsettings.json"); 18 | 19 | public static ConfigType Config { get; } = new(); 20 | } 21 | } 22 | 23 | namespace ProjectFilesGenerator.Types 24 | { 25 | partial class ConfigType() : ProjectDirectory("Config") 26 | { 27 | public ProjectFile database_json { get; } = new("Config/database.json"); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 20 | 21 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleContentItemsInNestedFolders#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static AssetsType Assets { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class AssetsType() : ProjectDirectory("Assets") 19 | { 20 | public ImagesType Images { get; } = new(); 21 | public partial class ImagesType 22 | { 23 | public ProjectFile logo_png { get; } = new("Assets/Images/logo.png"); 24 | } 25 | 26 | public ScriptsType Scripts { get; } = new(); 27 | public partial class ScriptsType 28 | { 29 | public ProjectFile app_js { get; } = new("Assets/Scripts/app.js"); 30 | } 31 | 32 | public StylesType Styles { get; } = new(); 33 | public partial class StylesType 34 | { 35 | public ProjectFile theme_css { get; } = new("Assets/Styles/theme.css"); 36 | } 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.DeepNestedStructure#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static RootType Root { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class RootType() : ProjectDirectory("Root") 19 | { 20 | public Level1Type Level1 { get; } = new(); 21 | public partial class Level1Type 22 | { 23 | public Level2Type Level2 { get; } = new(); 24 | public partial class Level2Type 25 | { 26 | public Level3Type Level3 { get; } = new(); 27 | public partial class Level3Type 28 | { 29 | public ProjectFile deep_txt { get; } = new("Root/Level1/Level2/Level3/deep.txt"); 30 | } 31 | 32 | } 33 | 34 | public ProjectFile file1_txt { get; } = new("Root/Level1/file1.txt"); 35 | } 36 | 37 | public ProjectFile file2_txt { get; } = new("Root/file2.txt"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/ProjectFiles/ProjectFiles.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.0 5 | true 6 | true 7 | false 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FilesInNestedDirectories#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ConfigType Config { get; } = new(); 13 | public static DataType Data { get; } = new(); 14 | } 15 | } 16 | 17 | namespace ProjectFilesGenerator.Types 18 | { 19 | partial class ConfigType() : ProjectDirectory("Config") 20 | { 21 | public DevType Dev { get; } = new(); 22 | public partial class DevType 23 | { 24 | public ProjectFile appsettings_dev_json { get; } = new("Config/Dev/appsettings.dev.json"); 25 | } 26 | 27 | public ProdType Prod { get; } = new(); 28 | public partial class ProdType 29 | { 30 | public ProjectFile appsettings_prod_json { get; } = new("Config/Prod/appsettings.prod.json"); 31 | } 32 | 33 | public ProjectFile appsettings_json { get; } = new("Config/appsettings.json"); 34 | } 35 | partial class DataType() : ProjectDirectory("Data") 36 | { 37 | public ProjectFile seed_sql { get; } = new("Data/seed.sql"); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Tests/MockOptionsProvider.cs: -------------------------------------------------------------------------------- 1 | class MockOptionsProvider( 2 | Dictionary> fileOptions, 3 | Dictionary? globalOptions = null) : 4 | AnalyzerConfigOptionsProvider 5 | { 6 | Dictionary globalOptions = globalOptions ?? new(); 7 | 8 | public override AnalyzerConfigOptions GlobalOptions => 9 | new MockGlobalOptions(globalOptions); 10 | 11 | public override AnalyzerConfigOptions GetOptions(SyntaxTree tree) => 12 | new MockOptions(new()); 13 | 14 | public override AnalyzerConfigOptions GetOptions(AdditionalText textFile) 15 | { 16 | var path = textFile.Path; 17 | if (fileOptions.TryGetValue(path, out var options)) 18 | { 19 | return new MockOptions(options); 20 | } 21 | 22 | return new MockOptions(new()); 23 | } 24 | 25 | class MockGlobalOptions(Dictionary options) : AnalyzerConfigOptions 26 | { 27 | public override bool TryGetValue(string key, out string value) => 28 | options.TryGetValue(key, out value!); 29 | } 30 | 31 | class MockOptions(Dictionary options) : AnalyzerConfigOptions 32 | { 33 | public override bool TryGetValue(string key, out string value) => 34 | options.TryGetValue(key, out value!); 35 | } 36 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithGlobbingPattern#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static TemplatesType Templates { get; } = new(); 13 | } 14 | } 15 | 16 | namespace ProjectFilesGenerator.Types 17 | { 18 | partial class TemplatesType() : ProjectDirectory("Templates") 19 | { 20 | public InvoiceType Invoice { get; } = new(); 21 | public partial class InvoiceType 22 | { 23 | public StylesType Styles { get; } = new(); 24 | public partial class StylesType 25 | { 26 | public ProjectFile invoice_css { get; } = new("Templates/Invoice/Styles/invoice.css"); 27 | } 28 | 29 | public ProjectFile invoice_html { get; } = new("Templates/Invoice/invoice.html"); 30 | } 31 | 32 | public ReceiptType Receipt { get; } = new(); 33 | public partial class ReceiptType 34 | { 35 | public ProjectFile receipt_html { get; } = new("Templates/Receipt/receipt.html"); 36 | } 37 | 38 | public ProjectFile email_html { get; } = new("Templates/email.html"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleConflicts.verified.txt: -------------------------------------------------------------------------------- 1 | { 2 | Diagnostics: [ 3 | { 4 | Message: File 'ProjectDirectory.txt' would generate property name 'ProjectDirectory' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 5 | Severity: Error, 6 | Descriptor: { 7 | Id: PROJFILES001, 8 | Title: File name conflicts with reserved property, 9 | MessageFormat: File '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 10 | Category: ProjectFiles, 11 | DefaultSeverity: Error, 12 | IsEnabledByDefault: true 13 | } 14 | }, 15 | { 16 | Message: File 'SolutionFile.json' would generate property name 'SolutionFile' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 17 | Severity: Error, 18 | Descriptor: { 19 | Id: PROJFILES001, 20 | Title: File name conflicts with reserved property, 21 | MessageFormat: File '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 22 | Category: ProjectFiles, 23 | DefaultSeverity: Error, 24 | IsEnabledByDefault: true 25 | } 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /src/ProjectFiles/Diagnostics.cs: -------------------------------------------------------------------------------- 1 | public static class Diagnostics 2 | { 3 | public static readonly DiagnosticDescriptor MinLangVersion = new( 4 | id: "PROJFILES003", 5 | title: "C# 14 or later is required", 6 | messageFormat: "This generator requires C# 14 or later to run", 7 | category: "ProjectFiles", 8 | DiagnosticSeverity.Error, 9 | isEnabledByDefault: true); 10 | 11 | 12 | public static readonly DiagnosticDescriptor ReservedFileNameConflict = new( 13 | id: "PROJFILES001", 14 | title: "File name conflicts with reserved property", 15 | messageFormat: "File '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory.", 16 | category: "ProjectFiles", 17 | DiagnosticSeverity.Error, 18 | isEnabledByDefault: true); 19 | 20 | public static readonly DiagnosticDescriptor ReservedDirectoryNameConflict = new( 21 | id: "PROJFILES002", 22 | title: "Directory name conflicts with reserved property", 23 | messageFormat: "Directory '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the directory or exclude its files from CopyToOutputDirectory.", 24 | category: "ProjectFiles", 25 | DiagnosticSeverity.Error, 26 | isEnabledByDefault: true); 27 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MixedFileAndDirectoryConflicts.verified.txt: -------------------------------------------------------------------------------- 1 | { 2 | Diagnostics: [ 3 | { 4 | Message: File 'ProjectFile.txt' would generate property name 'ProjectFile' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 5 | Severity: Error, 6 | Descriptor: { 7 | Id: PROJFILES001, 8 | Title: File name conflicts with reserved property, 9 | MessageFormat: File '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the file or exclude it from CopyToOutputDirectory., 10 | Category: ProjectFiles, 11 | DefaultSeverity: Error, 12 | IsEnabledByDefault: true 13 | } 14 | }, 15 | { 16 | Message: Directory 'SolutionDirectory/config.json' would generate property name 'SolutionDirectory' that conflicts with reserved MSBuild property. Rename the directory or exclude its files from CopyToOutputDirectory., 17 | Severity: Error, 18 | Descriptor: { 19 | Id: PROJFILES002, 20 | Title: Directory name conflicts with reserved property, 21 | MessageFormat: Directory '{0}' would generate property name '{1}' that conflicts with reserved MSBuild property. Rename the directory or exclude its files from CopyToOutputDirectory., 22 | Category: ProjectFiles, 23 | DefaultSeverity: Error, 24 | IsEnabledByDefault: true 25 | } 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /src/NugetTests/ComsumeTests.cs: -------------------------------------------------------------------------------- 1 | using ProjectFilesGenerator; 2 | 3 | [TestFixture] 4 | public class ComsumeTests 5 | { 6 | [Test] 7 | public void Recursive() => 8 | IsTrue(File.Exists(ProjectFiles.RecursiveDirectory.SomeFile_txt)); 9 | 10 | [Test] 11 | public void AtRoot() 12 | { 13 | IsTrue(File.Exists(ProjectFiles.fileAtRoot_txt)); 14 | IsTrue(File.Exists(ProjectFiles.globFileAtRoot_txt)); 15 | } 16 | 17 | [Test] 18 | public void Specific() 19 | { 20 | IsTrue(File.Exists(ProjectFiles.SpecificDirectory.Dir1.File1_txt)); 21 | IsTrue(File.Exists(ProjectFiles.SpecificDirectory.Dir1.File2_txt)); 22 | IsTrue(File.Exists(ProjectFiles.SpecificDirectory.Dir2.File4_txt)); 23 | IsTrue(File.Exists(ProjectFiles.SpecificDirectory.File3_txt)); 24 | } 25 | 26 | [Test] 27 | public void SameNamedDescendants() 28 | { 29 | IsTrue(File.Exists(ProjectFiles.SameNamedDescendants.SubDir1.NestedFile_txt)); 30 | IsTrue(File.Exists(ProjectFiles.SameNamedDescendants.SubDir2.NestedFile_txt)); 31 | } 32 | 33 | [Test] 34 | public void Config() => 35 | IsTrue(File.Exists(ProjectFiles.Config.appsettings_json)); 36 | [Test] 37 | public void LowerCase() => 38 | IsTrue(File.Exists(ProjectFiles.lower_case.lower_case_json)); 39 | 40 | [Test] 41 | public void Nested() 42 | { 43 | IsTrue(File.Exists(ProjectFiles.RecursiveDirectory.SubDir.NestedFile_txt)); 44 | IsTrue(File.Exists(ProjectFiles.Config.appsettings_json)); 45 | } 46 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleNestedDirectoriesWithSameName#ProjectFiles.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.g.cs 2 | // 3 | #nullable enable 4 | 5 | namespace ProjectFilesGenerator 6 | { 7 | using ProjectFilesGenerator.Types; 8 | 9 | /// Provides strongly-typed access to project files marked with CopyToOutputDirectory. 10 | static partial class ProjectFiles 11 | { 12 | public static ConfigType Config { get; } = new(); 13 | public static DataType Data { get; } = new(); 14 | public static ValidType Valid { get; } = new(); 15 | } 16 | } 17 | 18 | namespace ProjectFilesGenerator.Types 19 | { 20 | partial class ConfigType() : ProjectDirectory("Config") 21 | { 22 | public Config_Level1Type Config { get; } = new(); 23 | public partial class Config_Level1Type 24 | { 25 | public Config_Level2Type Config { get; } = new(); 26 | public partial class Config_Level2Type 27 | { 28 | public ProjectFile settings_xml { get; } = new("Config/Config/Config/settings.xml"); 29 | } 30 | 31 | } 32 | 33 | } 34 | partial class DataType() : ProjectDirectory("Data") 35 | { 36 | public Data_Level1Type Data { get; } = new(); 37 | public partial class Data_Level1Type 38 | { 39 | public ProjectFile config_json { get; } = new("Data/Data/config.json"); 40 | } 41 | 42 | } 43 | partial class ValidType() : ProjectDirectory("Valid") 44 | { 45 | public PathType Path { get; } = new(); 46 | public partial class PathType 47 | { 48 | public ProjectFile file_txt { get; } = new("Valid/Path/file.txt"); 49 | } 50 | 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Templates/ProjectFile.cs: -------------------------------------------------------------------------------- 1 | namespace ProjectFilesGenerator; 2 | 3 | using System.IO; 4 | using System.Text; 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | partial class ProjectFile(string path) 9 | { 10 | public string Path { get; } = path; 11 | 12 | public string FullPath => System.IO.Path.GetFullPath(Path); 13 | 14 | public override string ToString() => Path; 15 | 16 | public static implicit operator string(ProjectFile temp) => 17 | temp.Path; 18 | 19 | public static implicit operator FileInfo(ProjectFile temp) => 20 | new(temp.Path); 21 | 22 | public FileStream OpenRead() => 23 | File.OpenRead(Path); 24 | 25 | public StreamReader OpenText() => 26 | File.OpenText(Path); 27 | 28 | public string ReadAllText() => 29 | File.ReadAllText(Path); 30 | 31 | public string ReadAllText(Encoding encoding) => 32 | File.ReadAllText(Path, encoding); 33 | 34 | public FileInfo Info => new(Path); 35 | 36 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 37 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 38 | File.ReadAllTextAsync(Path, cancel); 39 | 40 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 41 | File.ReadAllTextAsync(Path, encoding,cancel); 42 | #else 43 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 44 | Task.FromResult(File.ReadAllText(Path)); 45 | 46 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 47 | Task.FromResult(File.ReadAllText(Path, encoding)); 48 | #endif 49 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoFiles#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentAtRoot#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.SingleFileAtRoot#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.AllMsBuildProperties#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentInDirectory#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.DeepNestedStructure#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.FilesWithKeywordNames#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsEnabled#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsFalse#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsNoFiles#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsNotSet#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ImplicitUsingsTrue#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleConflicts#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.MultipleFilesAtRoot#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NestedContentItems#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.NoFilesWithMetadata#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.OnlyProjectProperty#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.PartialMetadataMatch#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictCaseInsensitive#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithProjectFile#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ConflictWithSolutionFile#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } -------------------------------------------------------------------------------- /src/Tests/GeneratorTest.ContentWithGlobbingPattern#ProjectFiles.ProjectFile.g.verified.cs: -------------------------------------------------------------------------------- 1 | //HintName: ProjectFiles.ProjectFile.g.cs 2 | namespace ProjectFilesGenerator; 3 | 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | 9 | partial class ProjectFile(string path) 10 | { 11 | public string Path { get; } = path; 12 | 13 | public string FullPath => System.IO.Path.GetFullPath(Path); 14 | 15 | public override string ToString() => Path; 16 | 17 | public static implicit operator string(ProjectFile temp) => 18 | temp.Path; 19 | 20 | public static implicit operator FileInfo(ProjectFile temp) => 21 | new(temp.Path); 22 | 23 | public FileStream OpenRead() => 24 | File.OpenRead(Path); 25 | 26 | public StreamReader OpenText() => 27 | File.OpenText(Path); 28 | 29 | public string ReadAllText() => 30 | File.ReadAllText(Path); 31 | 32 | public string ReadAllText(Encoding encoding) => 33 | File.ReadAllText(Path, encoding); 34 | 35 | public FileInfo Info => new(Path); 36 | 37 | #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_0_OR_GREATER 38 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 39 | File.ReadAllTextAsync(Path, cancel); 40 | 41 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 42 | File.ReadAllTextAsync(Path, encoding,cancel); 43 | #else 44 | public Task ReadAllTextAsync(CancellationToken cancel = default) => 45 | Task.FromResult(File.ReadAllText(Path)); 46 | 47 | public Task ReadAllTextAsync(Encoding encoding, CancellationToken cancel = default) => 48 | Task.FromResult(File.ReadAllText(Path, encoding)); 49 | #endif 50 | } --------------------------------------------------------------------------------