diff --git a/sonar-dotnet-shared-library/src/main/java/org/sonarsource/dotnet/shared/plugins/protobuf/SymbolRefsImporter.java b/sonar-dotnet-shared-library/src/main/java/org/sonarsource/dotnet/shared/plugins/protobuf/SymbolRefsImporter.java index 96a08787a97..f886b6192b7 100644 --- a/sonar-dotnet-shared-library/src/main/java/org/sonarsource/dotnet/shared/plugins/protobuf/SymbolRefsImporter.java +++ b/sonar-dotnet-shared-library/src/main/java/org/sonarsource/dotnet/shared/plugins/protobuf/SymbolRefsImporter.java @@ -22,11 +22,12 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Optional; import java.util.function.UnaryOperator; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.api.batch.fs.InputFile; +import org.sonar.api.batch.fs.TextRange; import org.sonar.api.batch.sensor.SensorContext; import org.sonar.api.batch.sensor.symbol.NewSymbol; import org.sonar.api.batch.sensor.symbol.NewSymbolTable; @@ -48,6 +49,33 @@ public SymbolRefsImporter(SensorContext context, UnaryOperator toRealPat this.context = context; } + private static void addReferences(InputFile file, SymbolReferenceInfo.SymbolReference tokenInfo, NewSymbolTable symbolTable) { + var declarationRange = toTextRange(file, tokenInfo.getDeclaration()); + if (declarationRange.isPresent()) { + NewSymbol symbol = symbolTable.newSymbol(declarationRange.get()); + for (SonarAnalyzer.TextRange refTextRange : tokenInfo.getReferenceList()) { + var validatedReference = validatedReference(file, refTextRange, declarationRange.get()); + validatedReference.ifPresent(symbol::newReference); + } + } + } + + private static Optional validatedReference(InputFile file, SonarAnalyzer.TextRange refTextRange, TextRange declarationRange) { + var referenceRange = toTextRange(file, refTextRange); + if (referenceRange.isEmpty()) { + if (LOG.isDebugEnabled()) { + LOG.debug("The reported token was out of the range. File {}, Range {}", file.filename(), refTextRange); + } + return Optional.empty(); + } else if (declarationRange.overlap(referenceRange.get())) { + if (LOG.isDebugEnabled()) { + LOG.debug("The declaration token at {} overlaps with the referencing token {} in file {}", declarationRange, referenceRange.get(), file.filename()); + } + return Optional.empty(); + } + return referenceRange; + } + @Override void consumeFor(InputFile inputFile, SymbolReferenceInfo message) { for (SonarAnalyzer.SymbolReferenceInfo.SymbolReference tokenInfo : message.getReferenceList()) { @@ -73,21 +101,4 @@ boolean isProcessed(InputFile inputFile) { // we aggregate all symbol reference information, no need to process only the first protobuf file return false; } - - private static void addReferences(InputFile file, SymbolReferenceInfo.SymbolReference tokenInfo, NewSymbolTable symbolTable) { - var declarationRange = toTextRange(file, tokenInfo.getDeclaration()); - if (declarationRange.isPresent()) { - NewSymbol symbol = symbolTable.newSymbol(declarationRange.get()); - for (SonarAnalyzer.TextRange refTextRange : tokenInfo.getReferenceList()) { - var referenceRange = toTextRange(file, refTextRange); - if (referenceRange.isPresent()) { - symbol.newReference(referenceRange.get()); - } else if (LOG.isDebugEnabled()) { - LOG.debug("The reported token was out of the range. File {}, Range {}", file.filename(), refTextRange); - } - } - } else if (LOG.isDebugEnabled()) { - LOG.debug("The reported token was out of the range. File {}, Range {}", file.filename(), tokenInfo.getDeclaration()); - } - } } diff --git a/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RazorImporterTestBase.java b/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RazorImporterTestBase.java new file mode 100644 index 00000000000..003ac31b2ae --- /dev/null +++ b/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RazorImporterTestBase.java @@ -0,0 +1,69 @@ +/* + * SonarSource :: .NET :: Shared library + * Copyright (C) 2014-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarsource.dotnet.shared.plugins.protobuf; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.nio.file.Paths; +import org.junit.Before; +import org.junit.Rule; +import org.slf4j.event.Level; +import org.sonar.api.batch.fs.internal.DefaultInputFile; +import org.sonar.api.batch.fs.internal.FileMetadata; +import org.sonar.api.batch.fs.internal.TestInputFileBuilder; +import org.sonar.api.batch.sensor.internal.SensorContextTester; +import org.sonar.api.notifications.AnalysisWarnings; +import org.sonar.api.testfixtures.log.LogTester; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.mock; + +public class RazorImporterTestBase { + protected final static File TEST_DATA_DIR = new File("src/test/resources/RazorProtobufImporter"); + protected final SensorContextTester sensorContext = SensorContextTester.create(TEST_DATA_DIR); + @Rule + public LogTester logTester = new LogTester(); + protected DefaultInputFile CasesInputFile; + protected DefaultInputFile OverlapSymbolReferencesInputFile; + protected DefaultInputFile ProgramInputFile; + + protected static String fileName(String filePath) { + return Paths.get(filePath).getFileName().toString(); + } + + @Before + public void setUp() throws FileNotFoundException { + logTester.setLevel(Level.TRACE); + CasesInputFile = addTestFileToContext("Cases.razor"); + OverlapSymbolReferencesInputFile = addTestFileToContext("OverlapSymbolReferences.razor"); + ProgramInputFile = addTestFileToContext("Program.cs"); + } + + private DefaultInputFile addTestFileToContext(String testFilePath) throws FileNotFoundException { + var testFile = new File(TEST_DATA_DIR, testFilePath); + assertThat(testFile).withFailMessage("no such file: " + testFilePath).isFile(); + var inputFile = new TestInputFileBuilder("dummyKey", testFilePath) + .setMetadata(new FileMetadata(mock(AnalysisWarnings.class)).readMetadata(new FileReader(testFile))) + .build(); + sensorContext.fileSystem().add(inputFile); + return inputFile; + } +} diff --git a/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RoslynMetricsImporterTest.java b/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RazorMetricsImporterTest.java similarity index 71% rename from sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RoslynMetricsImporterTest.java rename to sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RazorMetricsImporterTest.java index f9c033fcb76..91215831df1 100644 --- a/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RoslynMetricsImporterTest.java +++ b/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RazorMetricsImporterTest.java @@ -19,69 +19,58 @@ */ package org.sonarsource.dotnet.shared.plugins.protobuf; +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Collections; import org.assertj.core.groups.Tuple; import org.junit.Before; import org.junit.Test; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.fs.internal.FileMetadata; -import org.sonar.api.batch.fs.internal.TestInputFileBuilder; -import org.sonar.api.batch.sensor.internal.SensorContextTester; import org.sonar.api.issue.NoSonarFilter; import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.FileLinesContext; import org.sonar.api.measures.FileLinesContextFactory; -import org.sonar.api.notifications.AnalysisWarnings; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.util.Collections; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import static org.sonarsource.dotnet.shared.plugins.ProtobufDataImporter.METRICS_FILENAME; -public class RoslynMetricsImporterTest { - private static final File TEST_DATA_DIR = new File("src/test/resources/RazorProtobufImporter"); - private static final String TEST_FILE_PATH = "Cases.razor"; - private static final File TEST_FILE = new File(TEST_DATA_DIR, TEST_FILE_PATH); +public class RazorMetricsImporterTest extends RazorImporterTestBase { private static final File PROTOBUF_FILE = new File(TEST_DATA_DIR, METRICS_FILENAME); @Before - public void before() { - assertThat(TEST_FILE).withFailMessage("no such file: " + TEST_FILE).isFile(); + @Override + public void setUp() throws FileNotFoundException { + super.setUp(); assertThat(PROTOBUF_FILE).withFailMessage("no such file: " + PROTOBUF_FILE).isFile(); } @Test - public void roslyn_metrics_are_imported() throws FileNotFoundException { - var inputFile = new TestInputFileBuilder("dummyKey", TEST_FILE_PATH) - .setMetadata(new FileMetadata(mock(AnalysisWarnings.class)).readMetadata(new FileReader(TEST_FILE))) - .build(); - - var sensorContext = SensorContextTester.create(TEST_FILE); - sensorContext.fileSystem().add(inputFile); - + public void roslyn_metrics_are_imported() { + var inputFile = CasesInputFile; var noSonarFilter = mock(NoSonarFilter.class); var fileLinesContext = mock(FileLinesContext.class); var fileLinesContextFactory = mock(FileLinesContextFactory.class); when(fileLinesContextFactory.createFor(any(InputFile.class))).thenReturn(fileLinesContext); - new MetricsImporter(sensorContext, fileLinesContextFactory, noSonarFilter, String::toString).accept(PROTOBUF_FILE.toPath()); + new MetricsImporter(sensorContext, fileLinesContextFactory, noSonarFilter, RazorImporterTestBase::fileName).accept(PROTOBUF_FILE.toPath()); var measures = sensorContext.measures(inputFile.key()); assertThat(measures).hasSize(7); assertThat(measures).extracting("metric", "value") .containsOnly( - Tuple.tuple(CoreMetrics.CLASSES, 1), - Tuple.tuple(CoreMetrics.STATEMENTS, 15), - Tuple.tuple(CoreMetrics.FUNCTIONS, 4), Tuple.tuple(CoreMetrics.COMPLEXITY, 5), + Tuple.tuple(CoreMetrics.FUNCTIONS, 3), Tuple.tuple(CoreMetrics.COMMENT_LINES, 0), Tuple.tuple(CoreMetrics.COGNITIVE_COMPLEXITY, 1), - Tuple.tuple(CoreMetrics.NCLOC, 14)); + Tuple.tuple(CoreMetrics.CLASSES, 0), + Tuple.tuple(CoreMetrics.NCLOC, 13), + Tuple.tuple(CoreMetrics.STATEMENTS, 6)); verify(noSonarFilter).noSonarInFile(inputFile, Collections.emptySet()); @@ -92,11 +81,10 @@ public void roslyn_metrics_are_imported() throws FileNotFoundException { verify(fileLinesContext).setIntValue(CoreMetrics.EXECUTABLE_LINES_DATA_KEY, 23, 1); verify(fileLinesContext).setIntValue(CoreMetrics.EXECUTABLE_LINES_DATA_KEY, 24, 1); - verify(fileLinesContext).setIntValue(CoreMetrics.NCLOC_DATA_KEY, 3, 1); - verify(fileLinesContext).setIntValue(CoreMetrics.NCLOC_DATA_KEY, 5, 1); + verify(fileLinesContext, times(2)).setIntValue(CoreMetrics.NCLOC_DATA_KEY, 3, 1); + verify(fileLinesContext, times(2)).setIntValue(CoreMetrics.NCLOC_DATA_KEY, 5, 1); verify(fileLinesContext).setIntValue(CoreMetrics.NCLOC_DATA_KEY, 8, 1); verify(fileLinesContext).setIntValue(CoreMetrics.NCLOC_DATA_KEY, 9, 1); - verify(fileLinesContext).setIntValue(CoreMetrics.NCLOC_DATA_KEY, 11, 1); verify(fileLinesContext).setIntValue(CoreMetrics.NCLOC_DATA_KEY, 13, 1); verify(fileLinesContext).setIntValue(CoreMetrics.NCLOC_DATA_KEY, 16, 1); verify(fileLinesContext).setIntValue(CoreMetrics.NCLOC_DATA_KEY, 18, 1); diff --git a/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RoslynSymbolRefsImporterTest.java b/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RazorSymbolRefsImporterTest.java similarity index 55% rename from sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RoslynSymbolRefsImporterTest.java rename to sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RazorSymbolRefsImporterTest.java index 99c50afa7c3..b68484d5a4d 100644 --- a/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RoslynSymbolRefsImporterTest.java +++ b/sonar-dotnet-shared-library/src/test/java/org/sonarsource/dotnet/shared/plugins/protobuf/RazorSymbolRefsImporterTest.java @@ -19,61 +19,60 @@ */ package org.sonarsource.dotnet.shared.plugins.protobuf; +import java.io.File; +import java.io.FileNotFoundException; +import java.nio.file.Paths; import org.junit.Before; -import org.junit.Rule; import org.junit.Test; import org.slf4j.event.Level; -import org.sonar.api.batch.fs.internal.FileMetadata; -import org.sonar.api.batch.fs.internal.TestInputFileBuilder; -import org.sonar.api.batch.sensor.internal.SensorContextTester; -import org.sonar.api.notifications.AnalysisWarnings; -import org.sonar.api.testfixtures.log.LogTester; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; import static org.sonarsource.dotnet.shared.plugins.ProtobufDataImporter.SYMBOLREFS_FILENAME; -public class RoslynSymbolRefsImporterTest { - - private static final File TEST_DATA_DIR = new File("src/test/resources/RazorProtobufImporter"); - private static final String TEST_FILE_PATH = "Cases.razor"; - private static final File TEST_FILE = new File(TEST_DATA_DIR, TEST_FILE_PATH); - - private final SensorContextTester sensorContext = SensorContextTester.create(TEST_DATA_DIR); +public class RazorSymbolRefsImporterTest extends RazorImporterTestBase { private final File protobuf = new File(TEST_DATA_DIR, SYMBOLREFS_FILENAME); - @Rule - public LogTester logTester = new LogTester(); - + @Override @Before - public void setUp() { - logTester.setLevel(Level.TRACE); + public void setUp() throws FileNotFoundException { + super.setUp(); assertThat(protobuf).withFailMessage("no such file: " + protobuf).isFile(); } @Test - public void test_symbol_refs_get_imported() throws FileNotFoundException { - var inputFile = new TestInputFileBuilder("dummyKey", TEST_FILE_PATH) - .setMetadata(new FileMetadata(mock(AnalysisWarnings.class)).readMetadata(new FileReader(TEST_FILE))) - .build(); - sensorContext.fileSystem().add(inputFile); + public void test_symbol_refs_get_imported_cases() { - var sut = new SymbolRefsImporter(sensorContext, String::toString); + var inputFile = CasesInputFile; + var sut = new SymbolRefsImporter(sensorContext, RazorImporterTestBase::fileName); sut.accept(protobuf.toPath()); sut.save(); // a symbol is defined at this location, and referenced at 3 other locations - assertThat(sensorContext.referencesForSymbolAt(inputFile.key(), 8, 30)).hasSize(1); + assertThat(sensorContext.referencesForSymbolAt(inputFile.key(), 8, 15)).hasSize(2); // ... other similar examples ... assertThat(sensorContext.referencesForSymbolAt(inputFile.key(), 16, 16)).hasSize(4); - assertThat(sensorContext.referencesForSymbolAt(inputFile.key(), 21, 17)).hasSize(1); assertThat(sensorContext.referencesForSymbolAt(inputFile.key(), 19, 15)).hasSize(3); + assertThat(sensorContext.referencesForSymbolAt(inputFile.key(), 21, 17)).isEmpty(); + + assertThat(logTester.logs(Level.DEBUG)).containsExactly( + "The declaration token at Range[from [line=1, lineOffset=0] to [line=1, lineOffset=17]] overlaps with the referencing token Range[from [line=1, lineOffset=6] to [line=1, lineOffset=23]] in file OverlapSymbolReferences.razor"); + } + + @Test + public void test_symbol_refs_get_imported_overlapSymbolReferences() { + + var inputFile = OverlapSymbolReferencesInputFile; + var sut = new SymbolRefsImporter(sensorContext, s -> Paths.get(s).getFileName().toString()); + sut.accept(protobuf.toPath()); + sut.save(); + + var references = sensorContext.referencesForSymbolAt(inputFile.key(), 1, 1); + assertThat(references) + .isNotNull() // The symbol declaration can be found, + .isEmpty(); // but there are no references, due to the overlap. - assertThat(logTester.logs(Level.DEBUG).get(0)).startsWith("The reported token was out of the range. File Cases.razor, Range start_line: 8"); + assertThat(logTester.logs(Level.DEBUG)).containsExactly( + "The declaration token at Range[from [line=1, lineOffset=0] to [line=1, lineOffset=17]] overlaps with the referencing token Range[from [line=1, lineOffset=6] to [line=1, lineOffset=23]] in file OverlapSymbolReferences.razor"); } } diff --git a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/BlazorWebAssembly.csproj b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/BlazorWebAssembly.csproj new file mode 100644 index 00000000000..3b27aab3146 --- /dev/null +++ b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/BlazorWebAssembly.csproj @@ -0,0 +1,12 @@ + + + {1250CC30-A343-4A10-A1DE-B1792ADB6244} + net8.0 + browser-wasm + + + + + + + \ No newline at end of file diff --git a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/OverlapSymbolReferences.razor b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/OverlapSymbolReferences.razor new file mode 100644 index 00000000000..a0f9bf1c596 --- /dev/null +++ b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/OverlapSymbolReferences.razor @@ -0,0 +1 @@ +@typeparam TSomeVeryLongName where TSomeVeryLongName : class \ No newline at end of file diff --git a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/Program.cs b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/Program.cs new file mode 100644 index 00000000000..69f3208b7a6 --- /dev/null +++ b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/Program.cs @@ -0,0 +1,6 @@ +namespace WebAss; + +public class Program +{ + public static void Main() { } +} diff --git a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/ReadMe.md b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/ReadMe.md index 909abcff27b..b68d1c8b827 100644 --- a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/ReadMe.md +++ b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/ReadMe.md @@ -1,5 +1,6 @@ -Please see the ReadMe.md file from `ProtobufImporterTest` folder that explains how to use the `ProtobufFilterTool`. +### How to re-create the pb files -Before running the tool please update the following fields in the `ProtobufFilterTool`: -- TEST_DATA_DIR should point to `"sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter"` -- TEST_FILENAME should point to `"Cases.razor"` \ No newline at end of file +- Create a Project in SonarQube (manual setup) +- Open a console in this directory +- Run the "Start" and the "Build" step as given by SonarQube +- Copy the pb files from `.sonarqube\out\0\output-cs` here diff --git a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/file-metadata.pb b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/file-metadata.pb index a8817b310f5..6a76a82de91 100644 --- a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/file-metadata.pb +++ b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/file-metadata.pb @@ -1,6 +1,4 @@ -m -bC:\src\work\sonar-dotnet\its\projects\RazorMetrics\obj\Debug\net7.0\RazorMetrics.GlobalUsings.g.csutf-8} -rC:\src\work\sonar-dotnet\its\projects\RazorMetrics\obj\Debug\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.csutf-8k -`C:\src\work\sonar-dotnet\its\projects\RazorMetrics\obj\Debug\net7.0\RazorMetrics.AssemblyInfo.csutf-8 -wMicrosoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Cases_razor.g.csutf-8 -zMicrosoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\_Imports_razor.g.csutf-8 \ No newline at end of file +; +2C:\Users\martin.strecker\Desktop\WebAss\Program.csutf-8Z +OC:\Users\martin.strecker\Desktop\WebAss\obj\Debug\net8.0\WebAss.AssemblyInfo.csutf-8r +gC:\Users\martin.strecker\Desktop\WebAss\obj\Debug\net8.0\.NETCoreApp,Version=v8.0.AssemblyAttributes.csutf-8 \ No newline at end of file diff --git a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/log.pb b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/log.pb index a34079e025e..214cd801117 100644 --- a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/log.pb +++ b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/log.pb @@ -1 +1 @@ -Roslyn version: 4.6.0.0Language version: CSharp11!Concurrent execution: enabledFile 'C:\src\work\sonar-dotnet\its\projects\RazorMetrics\obj\Debug\net7.0\RazorMetrics.GlobalUsings.g.cs' was recognized as generatedFile 'C:\src\work\sonar-dotnet\its\projects\RazorMetrics\obj\Debug\net7.0\.NETCoreApp,Version=v7.0.AssemblyAttributes.cs' was recognized as generatedFile 'C:\src\work\sonar-dotnet\its\projects\RazorMetrics\obj\Debug\net7.0\RazorMetrics.AssemblyInfo.cs' was recognized as generatedFile 'Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Cases_razor.g.cs' was recognized as generatedFile 'Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\_Imports_razor.g.cs' was recognized as generated \ No newline at end of file +Roslyn version: 4.8.0.0Language version: CSharp12!Concurrent execution: enabledFile 'Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\OverlapSymbolReferences_razor.g.cs' was recognized as razor generatedFile 'Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Cases_razor.g.cs' was recognized as razor generatedvrFile 'C:\Users\martin.strecker\Desktop\WebAss\obj\Debug\net8.0\WebAss.AssemblyInfo.cs' was recognized as generatedFile 'C:\Users\martin.strecker\Desktop\WebAss\obj\Debug\net8.0\.NETCoreApp,Version=v8.0.AssemblyAttributes.cs' was recognized as generated \ No newline at end of file diff --git a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/metrics.pb b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/metrics.pb index 2665d264882..cc9af0f4baa 100644 --- a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/metrics.pb +++ b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/metrics.pb @@ -1,2 +1,4 @@ -0 - Cases.razor 8r x  \ No newline at end of file +L +EC:\Users\martin.strecker\Desktop\WebAss\OverlapSymbolReferences.razor8rU +3C:\Users\martin.strecker\Desktop\WebAss\Cases.razor 8r  x A +2C:\Users\martin.strecker\Desktop\WebAss\Program.cs 8r \ No newline at end of file diff --git a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/symrefs.pb b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/symrefs.pb index 69300e6f7e5..3d951da6124 100644 --- a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/symrefs.pb +++ b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/symrefs.pb @@ -1,6 +1,14 @@ - - Cases.razor - % &7 82 -   ) 5 ( -     '  -    \ No newline at end of file +[ +EC:\Users\martin.strecker\Desktop\WebAss\OverlapSymbolReferences.razor +   +3C:\Users\martin.strecker\Desktop\WebAss\Cases.razor +  ( )2 +    & ( +     '  + + L +2C:\Users\martin.strecker\Desktop\WebAss\Program.cs + +  + +  \ No newline at end of file diff --git a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/token-cpd.pb b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/token-cpd.pb index 3cfba548bbf..d7dafb37167 100644 --- a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/token-cpd.pb +++ b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/token-cpd.pb @@ -1,325 +1,20 @@ -# -wMicrosoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Cases_razor.g.cs - namespace  - RazorMetrics -  -{  -[  -global  -::  - Microsoft  -.  - -AspNetCore ! -.! " - -Components" , -., - -RouteAttribute- ; -(; < -$str< D -)D E -]E F -public - -partial  -class  -Cases  -:  -global! ' -::' ) - Microsoft) 2 -.2 3 - -AspNetCore3 = -.= > - -Components> H -.H I - ComponentBaseI V -{  - protected  -override  -void  -BuildRenderTree / -(/ 0 -global0 6 -::6 8 - Microsoft8 A -.A B - -AspNetCoreB L -.L M - -ComponentsM W -.W X - RenderingX a -.a b -RenderTreeBuilderb s - __buildert } -)} ~ -{  - __builder  -.  - OpenElement ! -(! " -$num" # -,# $ -$str% ( -)( ) -;) * - __builder  -.  - -AddContent  -( ! -$num! " -," # -$str$ 5 -)5 6 -;6 7 - __builder  -. - - -AddContent -  -(  -$num  -,  - currentCount $ -)$ % -;% & - __builder""  -.""  - CloseElement"" " -(""" # -)""# $ -;""$ % - __builder##  -.##  -AddMarkupContent## & -(##& ' -$num##' ( -,##( ) -$str##* 0 -)##0 1 -;##1 2 - __builder&&  -.&& - - -AddContent&& -  -(&&  -$num&&  -,&&  - currentCount&& $ -)&&$ % -;&&% & -for--  -(--  -int--  -i--  -=-- ! -$num--" # -;--# $ -i--% & -<--' ( - currentCount--) 5 -;--5 6 -i--7 8 -++--8 : -)--: ; -{..  -}..  - __builder33  -.33  - OpenElement33 ! -(33! " -$num33" # -,33# $ -$str33% - -)33- . -;33. / - __builder44  -.44  - AddAttribute44 " -(44" # -$num44# $ -,44$ % -$str44& / -,44/ 0 -global441 7 -::447 9 - Microsoft449 B -.44B C - -AspNetCore44C M -.44M N - -Components44N X -.44X Y - EventCallback44Y f -.44f g -Factory44g n -.44n o -Create44o u -<44u v -global44v | -::44| ~ - Microsoft 44~  -. -44  - -AspNetCore -44  -. -44  - -Components -44  -. -44  -Web -44  -. -44  -MouseEventArgs -44  -> -44  -( -44  -this -44  -, -44  -IncrementCount77  -)<<  -)<<  -;<<  - __builder==  -.==  - -AddContent==  -(== ! -$num==! " -,==" # -$str==$ / -)==/ 0 -;==0 1 - __builder>>  -.>>  - CloseElement>> " -(>>" # -)>># $ -;>>$ % - __builder??  -.??  -AddMarkupContent?? & -(??& ' -$num??' ( -,??( ) -$str??* 0 -)??0 1 -;??1 2 - __builderBB  -.BB - - -AddContentBB -  -(BB  -$numBB  -,BB  -IncrementAmountBB ' -)BB' ( -;BB( ) -}GG  -privateLL  -intLL  - currentCountLL  -=LL  -$numLL  -;LL ! -[NN  - ParameterNN  -]NN  -publicOO - -intOO  -IncrementAmountOO  -{OO  -getOO! $ -;OO$ % -setOO& ) -;OO) * -}OO+ , -=OO- . -$numOO/ 0 -;OO0 1 -privateQQ  -voidQQ  -IncrementCountQQ  -(QQ  -)QQ ! -{RR  - currentCountSS  -+=SS  -IncrementAmountSS ' -;SS' ( -IncrementAmountTT  -+=TT  -$numTT  -;TT  -}UU  -}ZZ  -}[[  -zMicrosoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\_Imports_razor.g.cs - namespace  - RazorMetrics -  -{  -public - -partial  -class  -_Imports ! -:" # -global$ * -::* , - Microsoft, 5 -.5 6 - -AspNetCore6 @ -.@ A - -ComponentsA K -.K L - ComponentBaseL Y -{  - protected  -override  -void  -BuildRenderTree / -(/ 0 -global0 6 -::6 8 - Microsoft8 A -.A B - -AspNetCoreB L -.L M - -ComponentsM W -.W X - RenderingX a -.a b -RenderTreeBuilderb s - __buildert } -)} ~ -{  -}  -}  -}  \ No newline at end of file + +2C:\Users\martin.strecker\Desktop\WebAss\Program.cs + namespace  +WebAss +  +;  +public  +class  +Program  +{  +public + +static  +void  +Main  +(  +)  +{  +} ! +}  \ No newline at end of file diff --git a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/token-type.pb b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/token-type.pb index c91effbb2a7..e860d092c46 100644 --- a/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/token-type.pb +++ b/sonar-dotnet-shared-library/src/test/resources/RazorProtobufImporter/token-type.pb @@ -1,18 +1,5 @@ - -wMicrosoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Cases_razor.g.cs -  -           - -      -    - ; < D  -       ! ' I V       0 6 b s " # % ( ! " $ 5   ##' ( ##* 0 &&  --  --  --" # 33" # 33% - 44# $ 44& / 441 7 44Y f 44v | -44  -44  ==! " ==$ / ??' ( ??* 0 BB  LL  LL  LL  NN  OO - OO  OO! $ OO& ) OO/ 0 QQ  QQ  TT  -zMicrosoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\_Imports_razor.g.cs -  -           - -      -   -      ! $ * L Y       0 6 b s \ No newline at end of file + +2C:\Users\martin.strecker\Desktop\WebAss\Program.cs +  +       +     \ No newline at end of file